I was trying to export huge data to excel files on Toad.
I changed the
Toad Options -> Oracle -> General -> Max Varray Size tab. After then any query did not work. I can not select even a few columns.
I added the screenshot. Please could you help me?
if you are in trouble with Toad and couldn't find any solution to use it then I found this solution:
Utilities -> Copy User Settings -> Previous installation(of course if you have) or
Create a clean set (just i did)
It works like before.
Thank you.
Related
I am working with SQL right now and I am trying to write a bit of code that pulls a section of data from a database and saves it off to a file. This particular section of code is usually formatted all on one line and about 22,000-23,000 characters long on average. I can already pull some of the code but the pull stops after 4002 characters. My current code looks something like this:
SET HEADING OFF
SET ECHO OFF
SET LONG 100000
SET WRAP OFF
SPOOL output.txt
Select ________ (my select statement already works on its own);
SPOOL OFF;
I don't know the SQL language at all, I'm looking for some direction as to what functions I could research to help me out?
My end goal with this code is to be able to enter a value in, then have my code use that value to pull a value from one database. From there use both values to pull a long string of code from another database, would this kind of thing be possible in SQL?
Try adding this
SET SERVEROUPUT ON SIZE 1000000
I would really suggest that you try and view the SQLPlus Help.
It's really useful, and will explain all parameters to you, which is very useful.
Good Luck :)
In SQL Developer set
Tools > Preferences >> Navigate to Database > Worksheet > Max rows to print in a script(Increase number)
When I query for data that have arabic text in PL/SQL Developer, It is showed as question marks (????).
I am sure the data is correctly stored in DB because it shows on website properly, also on the server.
So I think it is a problem related to my PL/SQL Developer (v8.0.4.1514).
Is there any way to change how PL/SQL Developer shows/encodes arabic text?
How to check in what format/encoding the arabic text is stored?
My question might be missing some details, So Just ask me and also keep in mind that I am very beginner in PL/SQL and in SQL.
Thank you.
I found a solution (which might also work with other languages that shows as '????')
I changed the NLS_LANG in registry to AMERICAN_AMERICA.AL32UTF8
(I found 3 NLS_LANG's in registry, check with each one or just change them all like I did.)
then restarted PL/SQL developer, test a query and arabic text is showing normally.
Thank you all.
can you SET NLS_LANGUAGE to Arabic by ALTER SESSION SET NLS_LANGUAGE = 'ARABIC'
it could be the solution, if not can you provide more information about O/S and it's version, ... etc
There might be multiple instance of oracle installed so you must set default enconding for all of them. Just follow this instructions:
Open reg edit and go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Oracle. There is one or more keys related to each instance:
For each of this keys right click and create a string value named NLS_LANG if not already there:
Then set it's value to AMERICAN_AMERICA.AL32UTF8 and done just refresh your query in PL/SQL.
in registery find NLS_LANG and change its value from AMERICAN_AMERICA.WE8MSWIN1252 to AMERICAN_AMERICA.UTF8
it works fine for me for persian characters.
In IntelliJ IDEA 11.0.1 I connected Data Source to Oracle database.
When I open an *.sql file and type
SELECT * FROM
I see in code completion list of available tables. Also table columns of selected table are available in WHERE part of statement
But when I type
INSERT INTO
No table is available in code completion.
The same for SQL console.
Looks like a known bug. It's already fixed in IDEA 12 EAP and will be also fixed in IDEA 11.1.4 (not released at the moment of writing this answer).
I am using SQL Server Management Studio.
I wish to save the results of a query to an excel file.
I choose "save as" and then save to CSV file which I can open in excel. All good except I am missing column headers, any ideas how I get them exported?
Tools > Options > Query Results > SQL Server > Results to Text (or Grid if you want) > Include columns headers in the result set
You might need to close and reopen SSMS after changing this option.
On the SQL Editor Toolbar you can select save to file without having to restart SSMS
Try the Export Wizard. In this example I select a whole table, but you can just as easily specify a query:
(you can also specify a query here)
Another possibility is to use the clipboard to copy and paste the results directly into Excel. Just be careful with General type Excel columns, as they can sometimes have unpredictable results, depending on your data. CTL-A anywhere in the result grid, and then right-click:
If you have trouble with Excel's General format doing undesired conversions, select the blank columns in Excel before you paste and change the format to "text".
At least in SQL Server 2012, you can right click in the query window and select Query Options. From there you can select Include Headers for grid and/or text and have the Save As work the way you want it without restarting SSMS.
You'll still need to change it in Tools->Options in the menu bar to have new query windows use those settings by default.
The settings which has been advised to change in #Diego's accepted answer might be good if you want to set this option permanently. Permanently means it'll apply to all future query sessions that you open within SQL Server Management Studio(SSMS). This is usually not the case. Also, changing this setting requires restarting SQL Server Management Studio (SSMS). This is again a not-so-nice experience in case there are many unsaved query session windows open and you are in the middle of debugging something.
SQL Server gives a much slicker option of changing this setting on per session basis which is very quick and convenient. I'm detailing the steps below using query options window:
Right click in query editor window. Now, click Query Options... in the context menu as shown below:
Select Grid under Results node in the left navigation pane. Now, check the Include column headers when copying or saving the results check box as shown below:
That's it. Now, your current query session will start honouring your settings with immediate effect. You don't need restarting SSMS. Also, this setting won't be propagated to any future session either. Effectively, changing this setting on a per session basis is much less noisy.
The same problem exists in Visual Studio, here's how to fix it there:
Go to:
Tools > Options > SQL Server Tools > Transact-SQL Editor > Query Results > Results To Grid
Now click the check box to true: "Include column headers when copying or saving the results"
Select your results by clicking in the top left corner, right click and select "Copy with Headers".
Paste in excel.
Done!
Got here when looking for a way to make SSMS properly escape CSV separators when exporting results.
Guess what? - this is actually an option, and it is unchecked by default. So by default, you get broken CSV files (and may not even realize it, esp. if your export is large and your data doesn't have commas normally) - and you have to go in and click a checkbox so that your CSVs export correctly!
To me, this seems like a monumentally stupid design choice and an apt metaphor for Microsoft's approach to software in general ("broken by default, requires meaningless ritualistic actions to make trivial functionality work").
But I will gladly donate $100 to a charity of respondent's choice if someone can give me one valid real-life reason for this option to exist (i.e., an actual scenario where it was useful).
In SQL Server 2014 Management Studio the setting is at:
Tools > Options > Query Results > SQL Server > Results to Text > Include column headers in the result set.
I also face the same issue. When I used right click in the query window and select Query Options. But header rows does not show up in output CSV file.
Then I logoff the server, login again and run the script. Then it worked.
I've done a fair amount of tinkering and searching and the best option seems to be either:
sending output to text and copy/pasting into a text file or Excel OR
outputting to a somewhat unorthodox .rpt file, which I'm not sure what you'd do with--opening it in Excel doesn't preserve formatting present in the original output.
For what seems like a pretty common task, I'm surprised there isn't a simpler way to do this.
Can anyone suggest an easier way to go about this than the two methods I outlined?
Oh, and for what it's worth, I'm working on SQL Server 2008.
How about the BCP utility? http://msdn.microsoft.com/en-us/library/ms189569.aspx
Even through the SSMS GUI, it's still a relatively PITA process:
Plan A:
Tools, Options, Query Results, Results to Text
<= Change output format from "fixed columns" to "delimit by tabs"
At that point, you can "Save results to File", and specify a .csv file
Plan B: fire up your favorite scripting language (like vb.net, for example) and just write a program that does the SQL query and writes the .csv. 10 lines, tops :)
Plan C: Yet another approach is to use some external program to do the query and convert the results for you. SQL Server comes with "BCP". You can easily write a .bat file to invoke it:
http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/
'Hope that helps
Are you using SQL Server Management Studio? If so, when you open a new query window, you can select to send output to a file. Query Menu -> Results To -> Results to File.
Chris, this is actually super-easy.
If your query results get displayed in the grid (as is the default), just right-click on the grid and choose Save Results As....
From within MSSQL Management Studio, you can right-click on your database and select "Tasks" -> "Export Data". It starts-up a wizard that allows you to pick your data source. On the "Destination" page you can select "Microsoft Excel" or "Flat File Destination". The next page in the wizard allows you to specify data from one or more tables, or a custom query to get your data. If you chose "Flat File Destination" before, the next page allows you to set your own delimiters.
Another option is to pull it into Excel from SQL
Run your query and from the Results tab do Ctrl-a to select all, and paste this into Excel.