September 8, 2004 at 10:00 am
I'm trying to run the following with SQLCMD in SQL Express 2005:
DECLARE @FileName varchar(50),
@bcpCommand varchar(2000)
SET @FileName = REPLACE('c:\authors_'+CONVERT(char(8),GETDATE(),1)+'.txt','/','-')
SET @bcpCommand = 'bcp "SELECT * FROM QA..SSC_SURVEY_RESULTS" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -S .\sqlexpress -U sa -P test -c'
EXEC master..xp_cmdshell @bcpCommand
I get a connection error when trying, but I'm connecting the same way that I do to run SQLCMD. Am I missing something or is there a better way to export to a file using SQL Epress. Thanks.....
September 13, 2004 at 8:00 am
This was removed by the editor as SPAM
September 13, 2004 at 2:36 pm
Try run this and get the result and try run it from commend. I don't know much about SQL Express 2005 but assume they are the same as regular sql..
DECLARE @FileName varchar(50),
@bcpCommand varchar(2000)
SET @FileName = REPLACE('c:\authors_'+CONVERT(char(8),GETDATE(),1)+'.txt','/','-')
SET @bcpCommand = 'bcp "SELECT * FROM QA..SSC_SURVEY_RESULTS" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -S .\sqlexpress -U sa -P test -c'
print @bcpCommand
BTW, I don't like using " .\sqlexpress ". Have you tried to using full instance name?
September 13, 2004 at 3:43 pm
I actually got it to work on another server that was installed as a default instance with mixed mode authentication. Its got something to do with the naming conventions as you said I'd imagine. Any rate I just ended up exporting the file from that machine and then ftp'ing the file to a box in our building that imports the text file into a SQL 2000 server. Thanks for the tip.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply