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.
Author |
Topic |
ccrespo
Yak Posting Veteran
59 Posts |
Posted - 2007-08-10 : 14:44:37
|
is there any way to get this out into csv?DECLARE @FileName varchar(50), @bcpCommand varchar(2000)SET @FileName = 'c:\globalasatest.csv'--SET @FileName = REPLACE('c:\authors_'+CONVERT(char(8),GETDATE(),1)+'.txt','/','-')SET @bcpCommand = 'bcp "SELECT * FROM master..sysobjects" queryout "'SET @bcpCommand = @bcpCommand + @FileName + '" -U testuser -P testuser -c'EXEC master..xp_cmdshell @bcpCommand |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-08-10 : 14:47:10
|
First use a cmd window to make sure you got the syntax right, then use xp_cmdshell. From a cmd window:bcp "SELECT * FROM master..sysobjects" queryout C:\temp\SomeFile.csv -Sserver1 -T -c -t, -r\r\nTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|