| Author |
Topic |
|
Dan_2004
Starting Member
13 Posts |
Posted - 2004-02-27 : 12:45:55
|
Hi I have to read some tables from a db and i've to create a flat file. Since i am a new one with the sql syntax i would appreciate some hints to do it!I know how to do it with PL\SQL but i don't know if it's same with T-SQL?Tia,Dan |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-02-27 : 12:47:06
|
| You can use DTS or bcp.exe to send data from SQL Server to a text file. You can also use the import/export wizard if you aren't familiar with these.Tara |
 |
|
|
Dan_2004
Starting Member
13 Posts |
Posted - 2004-02-27 : 12:49:51
|
| Where can i see some examples for it? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-02-27 : 12:51:36
|
| SQL Server Books Online will have the information that you need.But to easily use the wizard, just right click on the database in Enterprise Manager, go to all tasks, then import or export. From there, it'll be a wizard so it'll walk you through everything.Tara |
 |
|
|
Dan_2004
Starting Member
13 Posts |
Posted - 2004-02-27 : 12:53:49
|
| Thanks for this information Tara, but i have to write it in a program code! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-02-27 : 13:05:10
|
| Well if the user machines will not have SQL client tools installed, then they won't be able to use DTS of bcp.exe.Could you post the PL\SQL code so that we can see if it can be rewritten for T-SQL? I know you can import data from a file using T-SQL only (see nigelrivett.net for an example), but I'm not sure you can go the other way around.Tara |
 |
|
|
Dan_2004
Starting Member
13 Posts |
Posted - 2004-02-27 : 13:20:15
|
| I send you an example of that i have to do:============================================File_Handle UTL_FILE.FILE_TYPE;::File_Handle := UTL_FILE.FOPEN(Output_Path_I, 'Test.TXT', 'W');::I've got a Cursor to work some data and some conditions after that i have a variable to assign some values::AP_Record := '999999999'/* Write record to Test output file. */UTL_FILE.PUT_LINE(File_Handle, AP_Record IN CHAR);::=========================================================Tia,Dan |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-02-27 : 13:21:36
|
| I don't think you are going to be able to do this with T-SQL. You'll have to get the data from SQL Server, then use whatever programming language the application is written in to do the export to file.Tara |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-02-27 : 14:40:42
|
| Tara, that's PL/SQL for Oracle...And that's the ONLY way to get data out in Oracle...through a cursor....Dan, what's the format of the file? Fixed width, TAB Delimeted?What?Can you post the DDL of the table.Do you have the sql server client side tools installed?Do you know what books online is?And when you say a "program" do you mean a procedure?There are no packages in sql server....Also there's no need for a cursor....Brett8-) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-02-27 : 15:10:56
|
| I know it's PL/SQL. I had him post it so that we can see what can be done in T-SQL.Tara |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-02-27 : 15:44:02
|
| ok......Brett8-) |
 |
|
|
|