May 27, 2011 at 2:27 am
This query worked fine
select 'PRINT ''' + '---' + REPLACE(SQLNAME,'.sql','') + '''' +
' :r ' + @FolderName + '\' + SQLNAME
from [dbo].[PATCHFILE]
I store the entire query into variable @sql. Then Received syntax error msg..
Anyone one know how to correct it ?
SELECT @sql = 'BCP "select 'PRINT ''' + '---' + REPLACE(SQLNAME,'.sql','') + '''' +
' :r ' + @FolderName + '\' + SQLNAME
from [dbo].[PATCHFILE]" queryout c:\filename.txt -c -t -U sa -P manager -S
TCPNET\SQLEXPRESS'
May 27, 2011 at 3:34 am
you have to run it from cmd prompt.
Ryan
//All our dreams can come true, if we have the courage to pursue them//
May 27, 2011 at 3:41 am
I think can run on SSMS... not necessary must in cmd mood
May 27, 2011 at 4:16 am
declare @folderName varchar(500)
declare @sql varchar(1000)
set @folderName = 'Empty'
select 'PRINT ''' + '---' + REPLACE(SQLNAME,'.sql','') + '''' +
' :r ' + @FolderName + '\' + SQLNAME
from [dbo].[PATCHFILE]
SELECT @sql = 'BCP "select ''PRINT ''' + '---' + REPLACE(SQLNAME,'.sql','') + '''' +
' :r ' + @FolderName + '\' + SQLNAME
from [dbo].[PATCHFILE] --'queryout c:\filename.txt -c -t -U sa -P manager -S TCPNET\SQLEXPRESS'
Select @sql
Regards,
Syed Jahanzaib Bin Hassan
BSCS | MCTS | MCITP | OCA | OCP | OCE | SCJP | IBMCDBA
My Blog
www.aureus-salah.com
May 27, 2011 at 6:22 am
BCP is an executable, it's run from the OS command prompt, not from SSMS.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply