bcp utility
You need not only the single quotes around the variable, but the double quote at the end. The best thing to do is to PRINT out the @SQL variable so you can look at it before execution, and make sure...
View Articlebcp utility
ok, I finally got it! Here is the syntax:SELECT @SQL ='bcp "Select * From Table A Where File_Name = '''+ @FileName +''' " queryout "C:\Production_Test\Folder\'+ @FileName +'.htm" -c -T -x' exec...
View Articlebcp utility
I would concatenate the string in the cursor definintion this way you only have to execute in the body of the cursor.DECLARE @sql NVARCHAR(500) DECLARE curCreateFiles CURSOR FAST_FORWARD FOR SELECT...
View Articlebcp utility
yes, i was using double quotes when I needed to be using single quotes around the variable and I changed that but now I get this! haha.usage: bcp {dbtable | query} {in | out | queryout | format}...
View Articlebcp utility
Your quotes look a little wonky. Try something like this for the select:SELECT@SQL ='bcp "Select * From Table A Where File_Name ='''+ @FileName +'''" queryout "C:\Production_Test\Folder\Test.htm" -c...
View Articlebcp utility
SELECT @SQL ='bcp "Select * From Table A Where File_Name ="'+ @FileName +' queryout "C:\Production_Test\Folder\Test.htm" -c -T -x' exec master..xp_cmdshell @SQLResults:Copy direction must be either...
View Articlebcp utility
I'm getting some kind of syntax error. I've never used this bcp utility before but If I execute with a name instead of variable it works fine.Mike
View Articlebcp utility
You can concatenate the file name variable and then execute:DECLARE @cmd SYSNAME;SET @cmd = 'bcp "Select * From dbo.Table A Where File_Name = ''' + @FileName + '''" queryout...
View Articlebcp utility
You can't pass a variable through EXEC; the scope is local to the procedure itself.However, you can pass the contents of that variable in a number of ways, for instance dynamic SQL:SET @sql =...
View Articlebcp utility
Hi, How can I pass a variable in as part of my bcp command in this cursor?DECLARE @FileName varchar(50)DECLARE EXPORT_CURSOR CURSORFORSELECT [File_Name]FROM Table AOPEN EXPORT_CURSORFETCH NEXTFROM...
View Article
More Pages to Explore .....