Export SQL Results to an excel file - Teradata Studio Express - teradata

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):

Related

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.

Select TOP x Rows in SSDT not SSMS

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.

export result into excel sheet from teradata sql assistant

I want to export the results into excel sheet by running the query in Teradata SQL Assistant.
I used copy paste but it didnt work
Thanks in advance.
If you return the answers to SQL Assistant you should be able to select Save Answerset from the File menu. You will then have the option to save it as a proper Excel file format.
If you export the answers to a flat file directly the delimited text file can in turn be opened with ease in Excel and then saved as a proper Excel file format (XLS, XLSX, etc.)
Select the whole excel worksheet you will paste into and set the number format to 'text'.
Now you can safely copy the data from the teradata sql assistant's query results and paste them into the spreadsheet.

How to insert Excel sheet file into SQL Server database?

I have an Excel sheet with more than 1000 records with customer details such as name, tele, address ...etc. and I want to know if I can save this sheet into a SQL Server database without inserting these records one by one from an aspx page, as I will have table in the database with customer details.
You can use SSMS's Import Data option, and use Excel as a data source and the table as the destination. This is a "run once" option. The second option, if you have to run this frequently, is to create an SSIS package for the import.

how to insert values from an excel sheet to sqlserver 2005

i have an excel sheet where i try to upload my excel sheet to sqlserver all having same colum name.
now i do not want to add dll files as an web reference in my project.
rather place the (dll) in an folder and call them dynamically in .cs side.
now i am doing like this
var assembly = Assembly.LoadFrom(#"d:\abc\microsoft.office.interop.excel.dll");
now in my .cs page i need to generate this property or methods of an excel dll which i have loaded dynamically
microsoft.officce.interop.excel.applicationClass excel= null
so that after loading my excel dl dynamically i need to sent values from my excel sheet to sqlserver 2005
is there a way to achive this
thank you
Can you not use OPENROWSET?
i.e Create a stored procedure that takes the path of the excel file which you want to insert into a given table. Use OPENROWSET function inside it to get a hold of the excel sheet.
Aother option is to possibly use SSIS to do this (SQL Server Integration Services). You would have more flexibility and could turn it into a small ETL project.
You could also use Excel code to transmit the data to the database either with a button or a macro. That only works if you can control the Excel file.
Just throwing other options out there.
First add a linked server to your Database instance..
Exec sp_dropServer 'myExcel',#droplogins='dropLogins'
EXEC sp_addlinkedserver 'myExcel',
'ACE 12.0',
'Microsoft.ACE.OLEDB.12.0',
'D:\SAABZX01D\EXCEL_books\ExpressLane\LMI\client carrier conversion.xls',
NULL,
'Excel 12.0'
exec sp_linkedServers
Then you insert to myTable in yourDatabase
Insert myTable(cola,colb,colc)
select cola,colb,colc from openQuery(myExcel,'select cola,colb,colc) from sheet1$')
You can open an excel file like a database (described here). After this you can load the data into some DataSet (I hope you know how to work with datasets) and upload all to the SqlServer database or to load in some custom structures, update some data if need and insert it into SqlServer database.

Resources