Select TOP x Rows in SSDT not SSMS - sql-server-data-tools

When using SSDT what I miss most is the ability to script the select statement of the top x rows like in SSMS.
Does anyone know if it's possible to turn that on somehow by an powertool or extension that enables the "Script As" functionality in SSDT?

You can right-click a database in the SQL Server Object Explorer (part of SSDT) and choose "New Query..." to get a query window. From there you can write and execute any query you like.
I've also got Redgate's SQL Prompt installed (I work for them), so typing "st100" gets me a top X query quickly -- the built-in intellisense may have something similar.

Related

Output column names instead of descriptions in SQL Assistant

Using the 16.20 SQL Assistant, the switch in the picture does not affect the output in the Query Results. I always see column descriptions there. Is there any way to get the names in the grid instead?
Works as expected only for .NET (which is the preferred connection anyway), but you probably connect using ODBC which seems to override SQLA's setting. Check "Use Colum Names" in the data source "Options"

Export SQL Results to an excel file - Teradata Studio Express

Teradata Studio Express, Version 16.2
I queried from an oracle database using TSE's SQL file editor (Since it is a non-TeraData database or else I would be using TSE's Teradata SQL editor). When querying from SQL File Editor, TSE provides the result within the SQL Results panel.
What I want to do is to export the result to an excel file but it does
not provide an option to do so. How do I approach this?
Below is a screenshot comparing result set panels. The left panel (querying from Teradata SQL Editor) has an option to export to excel but the right panel (Querying SQL File Editor) does not.
Finally figured it out.. Don't know why they don't provide a export option icon yet but here is solution:
Right click on the result table.
It will provides options. Select Export, then Current Result...
Then this window will appear (save it as a csv file and you should be able to open with Excel):

Export Multpile Tables Data as Insert Statements in to single file Oracle DB [duplicate]

The only thing I don't have an automated tool for when working with Oracle is a program that can create INSERT INTO scripts.
I don't desperately need it so I'm not going to spend money on it. I'm just wondering if there is anything out there that can be used to generate INSERT INTO scripts given an existing database without spending lots of money.
I've searched through Oracle with no luck in finding such a feature.
It exists in PL/SQL Developer, but errors for BLOB fields.
Oracle's free SQL Developer will do this:
http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html
You just find your table, right-click on it and choose Export Data->Insert
This will give you a file with your insert statements. You can also export the data in SQL Loader format as well.
You can do that in PL/SQL Developer v10.
1. Click on Table that you want to generate script for.
2. Click Export data.
3. Check if table is selected that you want to export data for.
4. Click on SQL inserts tab.
5. Add where clause if you don't need the whole table.
6. Select file where you will find your SQL script.
7. Click export.
Use a SQL function (I'm the author):
https://github.com/teopost/oracle-scripts/blob/master/fn_gen_inserts.sql
Usage:
select fn_gen_inserts('select * from tablename', 'p_new_owner_name', 'p_new_table_name')
from dual;
where:
p_sql – dynamic query which will be used to export metadata rows
p_new_owner_name – owner name which will be used for generated INSERT
p_new_table_name – table name which will be used for generated INSERT
p_sql in this sample is 'select * from tablename'
You can find original source code here:
http://dbaora.com/oracle-generate-rows-as-insert-statements-from-table-view-using-plsql/
Ashish Kumar's script generates individually usable insert statements instead of a SQL block, but supports fewer datatypes.
I have been searching for a solution for this and found it today. Here is how you can do it.
Open Oracle SQL Developer Query Builder
Run the query
Right click on result set and export
http://i.stack.imgur.com/lJp9P.png
You might execute something like this in the database:
select "insert into targettable(field1, field2, ...) values(" || field1 || ", " || field2 || ... || ");"
from targettable;
Something more sophisticated is here.
If you have an empty table the Export method won't work. As a workaround. I used the Table View of Oracle SQL Developer. and clicked on Columns. Sorted by Nullable so NO was on top. And then selected these non nullable values using shift + select for the range.
This allowed me to do one base insert. So that Export could prepare a proper all columns insert.
If you have to load a lot of data into tables on a regular basis, check out SQL Loader or external tables. Should be much faster than individual Inserts.
You can also use MyGeneration (free tool) to write your own sql generated scripts. There is a "insert into" script for SQL Server included in MyGeneration, which can be easily changed to run under Oracle.

Parameters to SQL in Chrome Dev Tools

Chrome's Developer Tools have a handy prompt on the Resources page where I can execute SQL on my actual WebSQL database. But if the SQL is parameterised like this:
select * from SomeTable where ImportantField = ?
I get a message like this:
Number of '?'s in statement string does not match argument count
I know this is a SQLite message, but I don't see an obvious way to supply the arguments in Chrome Dev Tools. Is it possible?
You are not possibly trying to execute that SQL as-is on the prompt, are you ?
If yes, then obviously you are wrong.
why do you care about ? when you are executing your SQL on console, why not simply use the value.
select * from SomeTable where ImportantField = 'yourValue'

How do I get the console output visible in Oracle Developer IDE?

I am a newb to Oracle. I used to use SQL Plus, and use set serveroutput on to see the results. However, when I started using Oracle Developer, my queries would run, however, I was not able to see the console or the results:
select *
from customer;
I assume that you mean "Oracle SQL Developer" application.
If yes, the in SQL Developer click on View option, then select Dbms output
DBMS Output window (panel) should appear somewhere on the screen.
Then, click on green plus sing in the DBMS-Output panel, and select a session you want to spy.

Resources