Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Import and export

Author  Topic 

samee
Starting Member

15 Posts

Posted - 2005-02-08 : 22:30:30
Hi all,

There is a export import wizard in sql server and I have used it.
What I need to know is the sql command code to do all the importing and exporting

Thank You.


JKNIGHT

nr
SQLTeam MVY

12543 Posts

Posted - 2005-02-08 : 22:36:05
The wizard will allow you to save a dts package which you can run using dtsrun.exe.
You can also use bcp to import and export if you are using text files.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

samee
Starting Member

15 Posts

Posted - 2005-02-11 : 01:17:50
Thanks
But what i need is the sql code for importing and exporting ok
Thank You.

JKNIGHT
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-02-11 : 01:40:41
Export to file
exec xp_cmdshell 'bcp "select * from dbName..tableName" queryout "D:\file.txt" -c'

Import from File

bulk insert TableName from 'D:\file.txt'
WITH (
DATAFILETYPE = 'char',
FIELDTERMINATOR = ' ',
TABLOCK
)

Madhivanan
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2005-02-11 : 02:13:13
http://www.mindsdoor.net/SQLTsql/BCP_quoted_CSV_Format_file.html
http://www.mindsdoor.net/SQLTsql/ImportTextFiles.html
http://www.mindsdoor.net/SQLTsql/WriteTextFile.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

samee
Starting Member

15 Posts

Posted - 2005-02-11 : 06:27:03
Thanks a Lot
So it is possible to export and import from and to any format like this
What i need is export and import to excel
Thank You.

JKNIGHT
Go to Top of Page

amardesai13
Starting Member

4 Posts

Posted - 2005-02-11 : 17:01:41
If you really wants to actual sql query who does import export...

Then follow this step...

The package you have designed from SQL server try to save as visual basic file and then it will create files in Modules.. Then open this module with Visual Basic and you will see sql query
which does import export things..

Another words just create a package in sql server which import/export data from sql server to excel then save as your package as visual basic file...

I hope that helps...

ADesai

Go to Top of Page
   

- Advertisement -