some one can tell if i can make a "where" clause inside the BCP , when i say : select * FROM tbl where flag=N , usually the where flag='N' works with the ' ' , but it gives no error when save the store procedure without it ' ' saves nicely the SP,
but
like this it saves well "SELECT * FROM tbl where flag=N" and
when i execute it, give a sql statement error "Error = [Microsoft][SQL Native Client][SQL Server]Invalid column name N."
i dont now , any help
PS: perhaps at the end of the BCP > -c -T , must have some more or less
Here the solution,
You have to use the escape sequence (Like \' or \" in other programming langauages).
SQL escape sequence for single quote is consecutive 2 single quotes ''.
EXEC xp_cmdshell 'bcp "SELECT * FROM tbl a where a.flag=''N''"
|||
Manivannan.D.Sekaran wrote:
Here the solution,
You have to use the escape sequence (Like \' or \" in other programming langauages).
SQL escape sequence for single quote is consecutive 2 single quotes ''.
EXEC xp_cmdshell 'bcp "SELECT * FROM tbl a where a.flag=''N''"
yes i tryed both ways with 'N' and "N" and it says the same error message
with this
'bcp "SELECT * FROM delta.dbo.tblRANGEL_O_STOCKS where updt="N"" queryout "'
Error = [Microsoft][SQL Native Client][SQL Server]Invalid column name 'N'.
with this says
'bcp "SELECT * FROM delta.dbo.tblRANGEL_O_STOCKS where updt= 'N' " queryout "'
Msg 102, Level 15, State 1, Procedure spDELTA_P1_RANGEL_STOCKS, Line 59
Incorrect syntax near ' " queryout "'.
|||Please copy and paste the following code,
Instead of 2 single quotes you are trying with 1 double quote.
Code Snippet
EXEC xp_cmdshell 'bcp "SELECT * FROM tbl a where a.flag=''N''" queryout F.txt -c -T'
|||
THANK YOU A LOT
and it was only a little thing like a '
No comments:
Post a Comment