October 29, 2007 at 9:52 am
Hi, I have two databeses
the first SQL SERVER 2000
the 2nd SQL EXPRESS 2005
I use this command:
sqlcmd -S db2000 -d p2000 -Q "SELECT * FROM dbo.table1" -s "|" -o "c:\table1.txt" -h-1
to read the content of table dbo.table and save it in c:\table1.txt
the content of c:\table1.txt is:
100|FIAT AUTO|10141|TORINO|FIAT GROUP AUTOMOBILES SP|0000000001
100|AUTOLUCE S|20127|MILANO|AUTOLUCE S.R.L.|0000000002
100|GOLDONI|41012|MIGLIARINA DI CARPI (MO)|GOLDONI S.P.A.|0000000003
100|SAME DEUTZ|24047|TREVIGLIO|SAME DEUTZ-FAHR ITALIA S.|0000000004
100|GRAFOPLAST|15077|PREDOSA (AL)|GRAFOPLAST S.P.A.|0000000005
100|CORDIANO A|89024|POLISTENA|CORDIANO AUTORICAMBI (LIM|0000000006
(7 rows affected)
Than I use this command:
sqlcmd -S .\sqlexpress -Q "bulk insert [database].[dbo].[table1] from 'c:\table1.txt' with (FIELDTERMINATOR = '|')"
to copy data from file to table.
It runs correcly if I delete the last 2 rows of c:\table1.txt
There is a method for don't print two last row in the file?
October 29, 2007 at 10:23 am
try this:
sqlcmd -S db2000 -d p2000 -Q "SET NOCOUNT ON SELECT * FROM dbo.table1" -s "|" -o "c:\table1.txt" -h-1
October 30, 2007 at 1:13 am
thank's!! It runs correctly!!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply