September 24, 2009 at 7:36 am
Hello All
I am trying to run the following BCP Command:
declare @bcpcommand Nvarchar(4000),
@LCAREA NVARCHAR(2)
SET @LCAREA='BL'
SET @BCPCOMMAND='bcp "SELECT char(34)+NEWTITLE,NEWFORENAME,NEWSURNAME,AD1,AD2,AD3,AD4,AD5,POSTCODE,REFNEW from [BLADE-SERV].DATA.DBO.mytablename where LEFT(POSTCODE,2)=''BL''" queryout "C:\WORK\ASHLEY\'+@LCAREA+'.TXT" -f c:\work\ASHLEY\bcpformatfile.fmt -T -k'
EXEC(@BCPCOMMAND)
I am getting an error when I am trying to execute it saying:
The identifier that starts with 'SELECT char(34)+NEWTITLE,NEWFORENAME,NEWSURNAME,AD1,AD2,AD3,AD4,AD5,POSTCODE,REFNEW from [BLADE-SERV].DATA.DBO.mytablename wher' is too long. Maximum length is 128.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'queryout'.
How do I get arounf this limitation in the BCP command?
Thanks in advance
September 24, 2009 at 8:37 am
You can create a view that has all the logic and in the bcp use “SELECT * FROM MyVIEW”.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
September 24, 2009 at 9:16 am
I'll give that a try...thanks for the response!
September 25, 2009 at 5:29 am
Hi
I have now created a view but I am still havving problems...I using the following syntax:
bcp "SELECT * from
.[dbo].[myviewname]" queryout "C:\WORK\'+@LCAREA+'.TXT" -f c:\work\ASHLEY\MIDAS\midas_bcpformatfile.fmt -T -k
And now I am getting an error message saying:
Incorrect syntax near 'queryout'.
!!PLEASE HELP!!
September 25, 2009 at 8:42 am
You can’t use a parameter in the command line and add it to the path of the file that should be created.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy