There are 8 separate queries I need to run and save to individual excel files. What's the best way of running this in toad rather than executing/saving each query?
Just figured out how to do this and I'm posting so that anyone else with the same problem can look at this as a possible solution.
Use the Automation Designer feature in TOAD for Oracle. Select export dataset and write in your query that you want exported and into what format you want it exported (I chose excel file). Repeat this process for all your queries. Select all "actions" and run.
Related
I have worked in SAS for much of my career and always found it easy to write a dataset out to csv using a proc export. I now am working in SQL Server and am not finding any similar functionality. Everything I find on the web refers to copy/paste the data into excel or using an export wizard. I don't like those options as the end goal is to automate this query and have the data output where it can be utilized by other programs. Is there any code based way to achieve this?
Are you using SSMS? CTRL-T then execute your query, you'll get a text (csv) result. Alternatively, Query -> Results to -> Results to Text. Alternatively, you can right click the results grid and select Save Results As
For automation, you can use SQL Server Agent to schedule a job the writes the output of a query to a file.
is it possible to feed data from the excel sheet into Toad SQL(as View)
Basically copy all the data from the sheet and keep it as VIEW in Toad, which I can use for my other queries
I’m sure there are a few ways to accomplish that. One example would be writing a script that reads the excel data into variables that could then be inserted into toad via command line or GUI. I’m not familiar with toad but I’m sure it can be done.
I want to transfer SQL query results to a new csv file. This is because I have placed my SQL query inside a loop which will generate export query results to csv file each time. I'm using MS SQL Server 2012. I don't want to take GUI option.
Sql Server is not really designed to import and export files. You can use bulk copy program but I dont think it works in tsql code (looping). You can use openrowset but you need to set a special flag that opens up your surface area of attack which some do not want to do.
The answer is SSIS (or a tool like Talend). It comes with Sql and is designed by MS as the go to tool for import and export from Sql. If you were to right click on the data base, choose tasks and then export the wizard eventually creates and executes an SSIS package.
I recommend you reconsider a GUI option.
ps - Another answer was to use save results as. I have heard of problems using this method including problems with delimiters or text qualified fields.
There are multiple ways to attain this. Either you can export the resultset using BCP or using IMPORT/ EXPORT or using CTRL+SHIFT+S (this will change the resultset to SAVE AS. Hope this may help.
We're doing a monthly data dump of our databases using Toad for Oracle's Export function. We've got some SQL queries to create statistics about the data. I'd like to compare the results of the current state with the last few dumps.
I can open the files with the Export File Browser in Toad (v11) and sort/filter the data using the GUI, but that's not powerful enough. Is there a way to query the dump files with SQL without having to take extra steps like creating a new schema and importing it?
By far the best way would be to reimport the data.
What's the easiest way to export data to excel from SQL Server 2000.
I want to do this from commands I can type into query analyzer.
I want the column names to appear in row 1.
In Query Analyzer, go to the Tools -> Options menu. On the Results tab, choose to send your output to a CSV file and select the "Print column headers" option. The CSV will open in Excel and you can then save it as a .XLS/.XLSX
Manual copy and paste is the only way to do exactly what you're asking. Query Analyzer can include the column names when you copy the results, but I think you may have to enable that somewhere in the options first (it's been a while since I used it).
Other alternatives are:
Write your own script or program to convert a result set into a .CSV or .XLS file
Use a DTS package to export to Excel
Use bcp.exe (but it doesn't include column names, so you have to kludge it)
Use a linked server to a blank Excel sheet and INSERT the data
Generally speaking, you cannot export data from MSSQL to a flat file using pure TSQL, because TSQL cannot manipulate anything outside the database (using a linked server is sort of cheating). So you usually need to use some sort of client application anyway, whether it's bcp.exe, dtswiz.exe or your own program.
And as a final comment, MSSQL 2000 is no longer supported (unless your company has an extended maintenance agreement) so you may want to look into upgrading at some point.