| Author |
Topic |
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-12 : 16:59:44
|
I found this code online that exports a query to txt, but its not executing properlyCREATE Procedure BCP_Text_File( @table varchar(100), @FileName varchar(100) ) as If exists(Select * from information_Schema.tables where table_name=@table) Begin Declare @str varchar(1000) set @str='Exec Master..xp_Cmdshell ''bcp "Select * from '+db_name()+'..'+@table+'" queryout "'+@FileName+'" -c''' Exec(@str) endelse Select 'The table '+@table+' does not exist in the database' When I execute with thisEXEC BCP_Text_File 'greatwolfcleanedup','C:\emp.txt' it results in...User name not provided, either use -U to provide the user name or use -T for Trusted Connectionusage: bcp {dbtable | query} {in | out | queryout | format} datafile [-m maxerrors] [-f formatfile] [-e errfile] [-F firstrow] [-L lastrow] [-b batchsize] [-n native type] [-c character type] [-w wide character type] [-N keep non-text native] [-V file format version] [-q quoted identifier] [-C code page specifier] [-t field terminator] [-r row terminator] [-i inputfile] [-o outfile] [-a packetsize] [-S server name] [-U username] [-P password] [-T trusted connection] [-v version] [-R regional enable] [-k keep null values] [-E keep identity values] [-h "load hints"] [-x generate xml format file]NULLNot sure what that means, can anybody help? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-12 : 17:08:55
|
[code]DECLARE @Str VARCHAR(1000) SET @Str = 'bcp "SELECT * FROM ' + QUOTENAME(DB_NAME()) + '..' + QUOTENAME(@Table) + '" queryout "' + @FileName + '" -c'EXEC master..xp_CmdShell @Str[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-12 : 17:15:02
|
What a coincidence they use same table/file work name "greatwolfcleanedup"!Must be class mates then. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-12 : 21:52:23
|
quote: Originally posted by Peso What a coincidence they use same table/file work name "greatwolfcleanedup"!Must be class mates then. E 12°55'05.25"N 56°04'39.16"
this isn't homework, i know you guys dont like that. i changed names because i didnt like the other onequote: Originally posted by Peso
DECLARE @Str VARCHAR(1000) SET @Str = 'bcp "SELECT * FROM ' + QUOTENAME(DB_NAME()) + '..' + QUOTENAME(@Table) + '" queryout "' + @FileName + '" -c'EXEC master..xp_CmdShell @Str E 12°55'05.25"N 56°04'39.16"
I used this instead of the original code and executed withEXEC BCP_Text_File 'greatwolfcleanedup','C:\emp.txt'but it still returned withUser name not provided, either use -U to provide the user name or use -T for Trusted Connectionusage: bcp {dbtable | query} {in | out | queryout | format} datafile [-m maxerrors] [-f formatfile] [-e errfile] [-F firstrow] [-L lastrow] [-b batchsize] [-n native type] [-c character type] [-w wide character type] [-N keep non-text native] [-V file format version] [-q quoted identifier] [-C code page specifier] [-t field terminator] [-r row terminator] [-i inputfile] [-o outfile] [-a packetsize] [-S server name] [-U username] [-P password] [-T trusted connection] [-v version] [-R regional enable] [-k keep null values] [-E keep identity values] [-h "load hints"] [-x generate xml format file]NULL |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-13 : 00:54:01
|
Yes, you have to provide login information since bcp is an out-of-process application. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-13 : 11:02:20
|
quote: Originally posted by Peso Yes, you have to provide login information since bcp is an out-of-process application. E 12°55'05.25"N 56°04'39.16"
So like this...? trying nowDECLARE @Str VARCHAR(1000) SET @Str = 'bcp "SELECT * FROM ' + QUOTENAME(DB_NAME()) + '..' + QUOTENAME(@Table) + '" queryout "' + @FileName + '" -c -U sqlchiq -P mypasswordhere'EXEC master..xp_CmdShell @Str if those were my login requirements of course :) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-13 : 11:09:47
|
Also remember to supply server name! E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-13 : 11:10:34
|
| It seemed like it worked...EXEC BCP_Text_File 'greatwolfcleanedup','C:\emp.txt'result wasNULLStarting copy...1000 rows successfully bulk-copied to host-file. Total received: 10001000 rows successfully bulk-copied to host-file. Total received: 20001000 rows successfully bulk-copied to host-file. Total received: 30001000 rows successfully bulk-copied to host-file. Total received: 40001000 rows successfully bulk-copied to host-file. Total received: 50001000 rows successfully bulk-copied to host-file. Total received: 60001000 rows successfully bulk-copied to host-file. Total received: 70001000 rows successfully bulk-copied to host-file. Total received: 80001000 rows successfully bulk-copied to host-file. Total received: 90001000 rows successfully bulk-copied to host-file. Total received: 100001000 rows successfully bulk-copied to host-file. Total received: 110001000 rows successfully bulk-copied to host-file. Total received: 120001000 rows successfully bulk-copied to host-file. Total received: 130001000 rows successfully bulk-copied to host-file. Total received: 140001000 rows successfully bulk-copied to host-file. Total received: 150001000 rows successfully bulk-copied to host-file. Total received: 160001000 rows successfully bulk-copied to host-file. Total received: 170001000 rows successfully bulk-copied to host-file. Total received: 180001000 rows successfully bulk-copied to host-file. Total received: 190001000 rows successfully bulk-copied to host-file. Total received: 200001000 rows successfully bulk-copied to host-file. Total received: 210001000 rows successfully bulk-copied to host-file. Total received: 220001000 rows successfully bulk-copied to host-file. Total received: 230001000 rows successfully bulk-copied to host-file. Total received: 240001000 rows successfully bulk-copied to host-file. Total received: 250001000 rows successfully bulk-copied to host-file. Total received: 260001000 rows successfully bulk-copied to host-file. Total received: 270001000 rows successfully bulk-copied to host-file. Total received: 280001000 rows successfully bulk-copied to host-file. Total received: 290001000 rows successfully bulk-copied to host-file. Total received: 300001000 rows successfully bulk-copied to host-file. Total received: 310001000 rows successfully bulk-copied to host-file. Total received: 320001000 rows successfully bulk-copied to host-file. Total received: 330001000 rows successfully bulk-copied to host-file. Total received: 340001000 rows successfully bulk-copied to host-file. Total received: 350001000 rows successfully bulk-copied to host-file. Total received: 360001000 rows successfully bulk-copied to host-file. Total received: 370001000 rows successfully bulk-copied to host-file. Total received: 380001000 rows successfully bulk-copied to host-file. Total received: 390001000 rows successfully bulk-copied to host-file. Total received: 400001000 rows successfully bulk-copied to host-file. Total received: 410001000 rows successfully bulk-copied to host-file. Total received: 420001000 rows successfully bulk-copied to host-file. Total received: 430001000 rows successfully bulk-copied to host-file. Total received: 440001000 rows successfully bulk-copied to host-file. Total received: 450001000 rows successfully bulk-copied to host-file. Total received: 460001000 rows successfully bulk-copied to host-file. Total received: 470001000 rows successfully bulk-copied to host-file. Total received: 480001000 rows successfully bulk-copied to host-file. Total received: 490001000 rows successfully bulk-copied to host-file. Total received: 500001000 rows successfully bulk-copied to host-file. Total received: 510001000 rows successfully bulk-copied to host-file. Total received: 520001000 rows successfully bulk-copied to host-file. Total received: 530001000 rows successfully bulk-copied to host-file. Total received: 540001000 rows successfully bulk-copied to host-file. Total received: 550001000 rows successfully bulk-copied to host-file. Total received: 560001000 rows successfully bulk-copied to host-file. Total received: 570001000 rows successfully bulk-copied to host-file. Total received: 580001000 rows successfully bulk-copied to host-file. Total received: 590001000 rows successfully bulk-copied to host-file. Total received: 600001000 rows successfully bulk-copied to host-file. Total received: 610001000 rows successfully bulk-copied to host-file. Total received: 620001000 rows successfully bulk-copied to host-file. Total received: 630001000 rows successfully bulk-copied to host-file. Total received: 640001000 rows successfully bulk-copied to host-file. Total received: 650001000 rows successfully bulk-copied to host-file. Total received: 660001000 rows successfully bulk-copied to host-file. Total received: 670001000 rows successfully bulk-copied to host-file. Total received: 680001000 rows successfully bulk-copied to host-file. Total received: 690001000 rows successfully bulk-copied to host-file. Total received: 700001000 rows successfully bulk-copied to host-file. Total received: 710001000 rows successfully bulk-copied to host-file. Total received: 720001000 rows successfully bulk-copied to host-file. Total received: 730001000 rows successfully bulk-copied to host-file. Total received: 740001000 rows successfully bulk-copied to host-file. Total received: 750001000 rows successfully bulk-copied to host-file. Total received: 760001000 rows successfully bulk-copied to host-file. Total received: 770001000 rows successfully bulk-copied to host-file. Total received: 780001000 rows successfully bulk-copied to host-file. Total received: 790001000 rows successfully bulk-copied to host-file. Total received: 800001000 rows successfully bulk-copied to host-file. Total received: 810001000 rows successfully bulk-copied to host-file. Total received: 820001000 rows successfully bulk-copied to host-file. Total received: 830001000 rows successfully bulk-copied to host-file. Total received: 840001000 rows successfully bulk-copied to host-file. Total received: 850001000 rows successfully bulk-copied to host-file. Total received: 860001000 rows successfully bulk-copied to host-file. Total received: 870001000 rows successfully bulk-copied to host-file. Total received: 880001000 rows successfully bulk-copied to host-file. Total received: 890001000 rows successfully bulk-copied to host-file. Total received: 900001000 rows successfully bulk-copied to host-file. Total received: 910001000 rows successfully bulk-copied to host-file. Total received: 920001000 rows successfully bulk-copied to host-file. Total received: 930001000 rows successfully bulk-copied to host-file. Total received: 940001000 rows successfully bulk-copied to host-file. Total received: 950001000 rows successfully bulk-copied to host-file. Total received: 960001000 rows successfully bulk-copied to host-file. Total received: 970001000 rows successfully bulk-copied to host-file. Total received: 980001000 rows successfully bulk-copied to host-file. Total received: 990001000 rows successfully bulk-copied to host-file. Total received: 1000001000 rows successfully bulk-copied to host-file. Total received: 1010001000 rows successfully bulk-copied to host-file. Total received: 1020001000 rows successfully bulk-copied to host-file. Total received: 1030001000 rows successfully bulk-copied to host-file. Total received: 1040001000 rows successfully bulk-copied to host-file. Total received: 1050001000 rows successfully bulk-copied to host-file. Total received: 1060001000 rows successfully bulk-copied to host-file. Total received: 1070001000 rows successfully bulk-copied to host-file. Total received: 1080001000 rows successfully bulk-copied to host-file. Total received: 1090001000 rows successfully bulk-copied to host-file. Total received: 1100001000 rows successfully bulk-copied to host-file. Total received: 1110001000 rows successfully bulk-copied to host-file. Total received: 1120001000 rows successfully bulk-copied to host-file. Total received: 1130001000 rows successfully bulk-copied to host-file. Total received: 1140001000 rows successfully bulk-copied to host-file. Total received: 1150001000 rows successfully bulk-copied to host-file. Total received: 1160001000 rows successfully bulk-copied to host-file. Total received: 1170001000 rows successfully bulk-copied to host-file. Total received: 1180001000 rows successfully bulk-copied to host-file. Total received: 1190001000 rows successfully bulk-copied to host-file. Total received: 1200001000 rows successfully bulk-copied to host-file. Total received: 1210001000 rows successfully bulk-copied to host-file. Total received: 1220001000 rows successfully bulk-copied to host-file. Total received: 1230001000 rows successfully bulk-copied to host-file. Total received: 1240001000 rows successfully bulk-copied to host-file. Total received: 1250001000 rows successfully bulk-copied to host-file. Total received: 1260001000 rows successfully bulk-copied to host-file. Total received: 1270001000 rows successfully bulk-copied to host-file. Total received: 1280001000 rows successfully bulk-copied to host-file. Total received: 1290001000 rows successfully bulk-copied to host-file. Total received: 1300001000 rows successfully bulk-copied to host-file. Total received: 1310001000 rows successfully bulk-copied to host-file. Total received: 1320001000 rows successfully bulk-copied to host-file. Total received: 1330001000 rows successfully bulk-copied to host-file. Total received: 1340001000 rows successfully bulk-copied to host-file. Total received: 1350001000 rows successfully bulk-copied to host-file. Total received: 1360001000 rows successfully bulk-copied to host-file. Total received: 1370001000 rows successfully bulk-copied to host-file. Total received: 1380001000 rows successfully bulk-copied to host-file. Total received: 1390001000 rows successfully bulk-copied to host-file. Total received: 1400001000 rows successfully bulk-copied to host-file. Total received: 1410001000 rows successfully bulk-copied to host-file. Total received: 1420001000 rows successfully bulk-copied to host-file. Total received: 1430001000 rows successfully bulk-copied to host-file. Total received: 1440001000 rows successfully bulk-copied to host-file. Total received: 1450001000 rows successfully bulk-copied to host-file. Total received: 1460001000 rows successfully bulk-copied to host-file. Total received: 1470001000 rows successfully bulk-copied to host-file. Total received: 1480001000 rows successfully bulk-copied to host-file. Total received: 1490001000 rows successfully bulk-copied to host-file. Total received: 1500001000 rows successfully bulk-copied to host-file. Total received: 1510001000 rows successfully bulk-copied to host-file. Total received: 1520001000 rows successfully bulk-copied to host-file. Total received: 1530001000 rows successfully bulk-copied to host-file. Total received: 1540001000 rows successfully bulk-copied to host-file. Total received: 1550001000 rows successfully bulk-copied to host-file. Total received: 1560001000 rows successfully bulk-copied to host-file. Total received: 1570001000 rows successfully bulk-copied to host-file. Total received: 1580001000 rows successfully bulk-copied to host-file. Total received: 1590001000 rows successfully bulk-copied to host-file. Total received: 1600001000 rows successfully bulk-copied to host-file. Total received: 1610001000 rows successfully bulk-copied to host-file. Total received: 1620001000 rows successfully bulk-copied to host-file. Total received: 1630001000 rows successfully bulk-copied to host-file. Total received: 1640001000 rows successfully bulk-copied to host-file. Total received: 1650001000 rows successfully bulk-copied to host-file. Total received: 1660001000 rows successfully bulk-copied to host-file. Total received: 1670001000 rows successfully bulk-copied to host-file. Total received: 1680001000 rows successfully bulk-copied to host-file. Total received: 1690001000 rows successfully bulk-copied to host-file. Total received: 1700001000 rows successfully bulk-copied to host-file. Total received: 1710001000 rows successfully bulk-copied to host-file. Total received: 1720001000 rows successfully bulk-copied to host-file. Total received: 1730001000 rows successfully bulk-copied to host-file. Total received: 1740001000 rows successfully bulk-copied to host-file. Total received: 1750001000 rows successfully bulk-copied to host-file. Total received: 1760001000 rows successfully bulk-copied to host-file. Total received: 1770001000 rows successfully bulk-copied to host-file. Total received: 1780001000 rows successfully bulk-copied to host-file. Total received: 1790001000 rows successfully bulk-copied to host-file. Total received: 1800001000 rows successfully bulk-copied to host-file. Total received: 1810001000 rows successfully bulk-copied to host-file. Total received: 1820001000 rows successfully bulk-copied to host-file. Total received: 1830001000 rows successfully bulk-copied to host-file. Total received: 1840001000 rows successfully bulk-copied to host-file. Total received: 1850001000 rows successfully bulk-copied to host-file. Total received: 1860001000 rows successfully bulk-copied to host-file. Total received: 1870001000 rows successfully bulk-copied to host-file. Total received: 1880001000 rows successfully bulk-copied to host-file. Total received: 1890001000 rows successfully bulk-copied to host-file. Total received: 1900001000 rows successfully bulk-copied to host-file. Total received: 1910001000 rows successfully bulk-copied to host-file. Total received: 1920001000 rows successfully bulk-copied to host-file. Total received: 1930001000 rows successfully bulk-copied to host-file. Total received: 1940001000 rows successfully bulk-copied to host-file. Total received: 1950001000 rows successfully bulk-copied to host-file. Total received: 1960001000 rows successfully bulk-copied to host-file. Total received: 1970001000 rows successfully bulk-copied to host-file. Total received: 1980001000 rows successfully bulk-copied to host-file. Total received: 1990001000 rows successfully bulk-copied to host-file. Total received: 2000001000 rows successfully bulk-copied to host-file. Total received: 2010001000 rows successfully bulk-copied to host-file. Total received: 2020001000 rows successfully bulk-copied to host-file. Total received: 2030001000 rows successfully bulk-copied to host-file. Total received: 2040001000 rows successfully bulk-copied to host-file. Total received: 2050001000 rows successfully bulk-copied to host-file. Total received: 2060001000 rows successfully bulk-copied to host-file. Total received: 2070001000 rows successfully bulk-copied to host-file. Total received: 2080001000 rows successfully bulk-copied to host-file. Total received: 2090001000 rows successfully bulk-copied to host-file. Total received: 2100001000 rows successfully bulk-copied to host-file. Total received: 2110001000 rows successfully bulk-copied to host-file. Total received: 2120001000 rows successfully bulk-copied to host-file. Total received: 2130001000 rows successfully bulk-copied to host-file. Total received: 2140001000 rows successfully bulk-copied to host-file. Total received: 2150001000 rows successfully bulk-copied to host-file. Total received: 2160001000 rows successfully bulk-copied to host-file. Total received: 2170001000 rows successfully bulk-copied to host-file. Total received: 2180001000 rows successfully bulk-copied to host-file. Total received: 2190001000 rows successfully bulk-copied to host-file. Total received: 2200001000 rows successfully bulk-copied to host-file. Total received: 2210001000 rows successfully bulk-copied to host-file. Total received: 2220001000 rows successfully bulk-copied to host-file. Total received: 2230001000 rows successfully bulk-copied to host-file. Total received: 2240001000 rows successfully bulk-copied to host-file. Total received: 2250001000 rows successfully bulk-copied to host-file. Total received: 2260001000 rows successfully bulk-copied to host-file. Total received: 2270001000 rows successfully bulk-copied to host-file. Total received: 2280001000 rows successfully bulk-copied to host-file. Total received: 2290001000 rows successfully bulk-copied to host-file. Total received: 2300001000 rows successfully bulk-copied to host-file. Total received: 2310001000 rows successfully bulk-copied to host-file. Total received: 2320001000 rows successfully bulk-copied to host-file. Total received: 2330001000 rows successfully bulk-copied to host-file. Total received: 2340001000 rows successfully bulk-copied to host-file. Total received: 2350001000 rows successfully bulk-copied to host-file. Total received: 2360001000 rows successfully bulk-copied to host-file. Total received: 2370001000 rows successfully bulk-copied to host-file. Total received: 2380001000 rows successfully bulk-copied to host-file. Total received: 2390001000 rows successfully bulk-copied to host-file. Total received: 2400001000 rows successfully bulk-copied to host-file. Total received: 2410001000 rows successfully bulk-copied to host-file. Total received: 2420001000 rows successfully bulk-copied to host-file. Total received: 2430001000 rows successfully bulk-copied to host-file. Total received: 2440001000 rows successfully bulk-copied to host-file. Total received: 2450001000 rows successfully bulk-copied to host-file. Total received: 2460001000 rows successfully bulk-copied to host-file. Total received: 2470001000 rows successfully bulk-copied to host-file. Total received: 2480001000 rows successfully bulk-copied to host-file. Total received: 2490001000 rows successfully bulk-copied to host-file. Total received: 2500001000 rows successfully bulk-copied to host-file. Total received: 2510001000 rows successfully bulk-copied to host-file. Total received: 2520001000 rows successfully bulk-copied to host-file. Total received: 2530001000 rows successfully bulk-copied to host-file. Total received: 2540001000 rows successfully bulk-copied to host-file. Total received: 2550001000 rows successfully bulk-copied to host-file. Total received: 2560001000 rows successfully bulk-copied to host-file. Total received: 2570001000 rows successfully bulk-copied to host-file. Total received: 2580001000 rows successfully bulk-copied to host-file. Total received: 2590001000 rows successfully bulk-copied to host-file. Total received: 2600001000 rows successfully bulk-copied to host-file. Total received: 2610001000 rows successfully bulk-copied to host-file. Total received: 2620001000 rows successfully bulk-copied to host-file. Total received: 2630001000 rows successfully bulk-copied to host-file. Total received: 2640001000 rows successfully bulk-copied to host-file. Total received: 2650001000 rows successfully bulk-copied to host-file. Total received: 2660001000 rows successfully bulk-copied to host-file. Total received: 2670001000 rows successfully bulk-copied to host-file. Total received: 2680001000 rows successfully bulk-copied to host-file. Total received: 2690001000 rows successfully bulk-copied to host-file. Total received: 2700001000 rows successfully bulk-copied to host-file. Total received: 2710001000 rows successfully bulk-copied to host-file. Total received: 2720001000 rows successfully bulk-copied to host-file. Total received: 2730001000 rows successfully bulk-copied to host-file. Total received: 2740001000 rows successfully bulk-copied to host-file. Total received: 2750001000 rows successfully bulk-copied to host-file. Total received: 2760001000 rows successfully bulk-copied to host-file. Total received: 2770001000 rows successfully bulk-copied to host-file. Total received: 2780001000 rows successfully bulk-copied to host-file. Total received: 2790001000 rows successfully bulk-copied to host-file. Total received: 2800001000 rows successfully bulk-copied to host-file. Total received: 2810001000 rows successfully bulk-copied to host-file. Total received: 2820001000 rows successfully bulk-copied to host-file. Total received: 2830001000 rows successfully bulk-copied to host-file. Total received: 2840001000 rows successfully bulk-copied to host-file. Total received: 2850001000 rows successfully bulk-copied to host-file. Total received: 2860001000 rows successfully bulk-copied to host-file. Total received: 2870001000 rows successfully bulk-copied to host-file. Total received: 2880001000 rows successfully bulk-copied to host-file. Total received: 2890001000 rows successfully bulk-copied to host-file. Total received: 2900001000 rows successfully bulk-copied to host-file. Total received: 2910001000 rows successfully bulk-copied to host-file. Total received: 2920001000 rows successfully bulk-copied to host-file. Total received: 2930001000 rows successfully bulk-copied to host-file. Total received: 2940001000 rows successfully bulk-copied to host-file. Total received: 2950001000 rows successfully bulk-copied to host-file. Total received: 2960001000 rows successfully bulk-copied to host-file. Total received: 2970001000 rows successfully bulk-copied to host-file. Total received: 2980001000 rows successfully bulk-copied to host-file. Total received: 2990001000 rows successfully bulk-copied to host-file. Total received: 3000001000 rows successfully bulk-copied to host-file. Total received: 3010001000 rows successfully bulk-copied to host-file. Total received: 3020001000 rows successfully bulk-copied to host-file. Total received: 3030001000 rows successfully bulk-copied to host-file. Total received: 3040001000 rows successfully bulk-copied to host-file. Total received: 3050001000 rows successfully bulk-copied to host-file. Total received: 3060001000 rows successfully bulk-copied to host-file. Total received: 3070001000 rows successfully bulk-copied to host-file. Total received: 3080001000 rows successfully bulk-copied to host-file. Total received: 3090001000 rows successfully bulk-copied to host-file. Total received: 3100001000 rows successfully bulk-copied to host-file. Total received: 3110001000 rows successfully bulk-copied to host-file. Total received: 3120001000 rows successfully bulk-copied to host-file. Total received: 3130001000 rows successfully bulk-copied to host-file. Total received: 3140001000 rows successfully bulk-copied to host-file. Total received: 3150001000 rows successfully bulk-copied to host-file. Total received: 316000NULL316041 rows copied.Network packet size (bytes): 4096Clock Time (ms.) Total : 5047 Average : (62619.58 rows per sec.)NULLBut there's no file called emp.txt on the C drive where I told it write to.I also tried to create a blank txt emp.txt where its suppose to write to as well and it didnt work. |
 |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-13 : 11:15:16
|
quote: Originally posted by Peso Also remember to supply server name! E 12°55'05.25"N 56°04'39.16"
I've added the server like soDECLARE @Str VARCHAR(1000) SET @Str = 'bcp "SELECT * FROM ' + QUOTENAME(DB_NAME()) + '..' + QUOTENAME(@Table) + '" queryout "' + @FileName + '"-c -U sqlchiq -P mypasswordhere -S 34.3.234.134'EXEC master..xp_CmdShell @Str but it still is giving the write successfully but no file is there |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-13 : 11:17:09
|
"C:\" is relative to SQL Server, not your local machine. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-13 : 11:19:53
|
quote: Originally posted by Peso "C:\" is relative to SQL Server, not your local machine. E 12°55'05.25"N 56°04'39.16"
Ahhh, I see it now, thank you very much peso! |
 |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-13 : 11:22:42
|
| There's probably no way to get it to write to the local machine is there? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-13 : 11:22:59
|
Thank you.All I did was reading out loud from Books Online. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-13 : 11:24:12
|
Yes there is.Use an UNC path name instead of local drive.DECLARE @Str VARCHAR(1000) SET @Str = 'bcp "SELECT * FROM ' + QUOTENAME(DB_NAME()) + '..' + QUOTENAME(@Table) + '" queryout "\\MyMachine\C$\' + @FileName + '"-c -U sqlchiq -P mypasswordhere -S 34.3.234.134'EXEC master..xp_CmdShell @Str Also found in Books Online. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|