Having an issue wth a bcp string

  • It looks like you have two single quotes before the select instead of a double quote 😛

     

  • Change the two single quotes before select and after DMP to a double quote.

    John

  • Thanks that helped a great deal, but now I am having some kind of issue on the other end. Because it now gives :

    "User name not provided, either use -U to provide the user name or use -T for Trusted Connection" So I just tried different quotes but nothing worked, and ideas here?

    Thank you

  • you do need to look at the output of your print command - that will show it what is wrong.

    try the following - removed some of the single quotes on the filename that most likely should not be there.

    and do you really want a filename with a space between DMP and the date portion?

    set @qry='bcp "select * from  ##TEMP1" queryout "\\DELLX2010\c$\Vend\Inter Data\to ID\DMP '+   CONVERT(VARCHAR(8), SYSDATETIME(), 112) +'_BK.txt"  -T -c -t,'
    print @qry

     

  • How are you going to connect - with Windows authentication or with a SQL login?  In the former case, use the -T switch; in the latter use -U and -P to specify the login name and the password.  It's all in here.

    John

  • Trusted connection

  • This is what my code now looks like:

         set @qry='bcp "select * from  ##TEMP1 " queryout "\\DELLX2010\c$\Vend\Inter Data\to ID\DMP " "'+   CONVERT(VARCHAR(8), SYSDATETIME(), 112) +'''" +"_BK.txt"  -T -c -t,'
    print @qry
    EXEC xp_cmdshell @qry
  • did you bother reading my reply?

  • Sorry, somehow I did not see your reply, maybe I needed to refresh. I will try this now.

    Thanks

Viewing 9 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply