April 14, 2020 at 2:45 pm
Hi,
I have been trying to do this for a while now to get this and, and while I have done this before without a problem, somehow I have something wrong; probably a quote or something. now maters what I do the file is not created and I get the following error message each time. "Copy direction must be either 'in', 'out' or 'format'."
If someone can show me what I am doing wrong I would greatly appreciate it.
Thank you
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
April 14, 2020 at 3:06 pm
It looks like you have two single quotes before the select instead of a double quote 😛
April 14, 2020 at 3:09 pm
Change the two single quotes before select and after DMP to a double quote.
John
April 14, 2020 at 3:41 pm
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
April 14, 2020 at 3:52 pm
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
April 14, 2020 at 3:55 pm
Trusted connection
April 14, 2020 at 4:00 pm
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
April 14, 2020 at 4:31 pm
did you bother reading my reply?
April 14, 2020 at 4:47 pm
Sorry, somehow I did not see your reply, maybe I needed to refresh. I will try this now.
Thanks
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply