January 21, 2013 at 4:53 am
hello all.
I used this procedure for export to xml file:
alter PROC makeXML
AS
DECLARE @myXml xml,@SQL nvarchar(max)
SET @myXml = (SELECT * FROM QMS_QmsBase FOR XML AUTO)
SET @sql= 'bcp "exec @myXml" QUERY OUT f:\azizi\filename.xml -w -r -t -SNik-Azizi -T'
EXEC Master..xp_CmdShell @sql
but get this error:
Procedure expects parameter 'command_string' of type 'varchar'
how to solve this error?thanks
January 21, 2013 at 5:19 am
thank you for your reply,
i use your note but get the same error:crying:
January 21, 2013 at 5:22 am
Missed one thing, the MyXML variable will need to be varchar too
SO you might as well just do the following
DECLARE @SQL varchar(max)
SET @SQL= 'bcp "SELECT column_names FROM QMS_QmsBase FOR XML AUTO" QUERY OUT f:\azizi\filename.xml -w -r -t -SNik-Azizi -T'
EXEC Master..xp_CmdShell @SQL
January 21, 2013 at 5:56 am
i use this:
alter PROC makeXML
AS
DECLARE @myXml xml,@SQL varchar(max)
SET @myXml = (SELECT QMS_QmsBaseName FROM QMS_QmsBase FOR XML AUTO)
--SET @sql= 'bcp "exec @myXml" QUERY OUT f:\azizi\filename.xml -w -r -t -SNik-Azizi -T'
EXEC Master..xp_CmdShell 'bcp "exec @myXml" QUERY OUT f:\azizi\filename.xml -w -r -t -SNik-Azizi -T'
--exec makeXML
and solve previouse error but sp doesnot work and result of its:
Copy direction must be either 'in', 'out' or 'format'.
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-x generate xml format file]
[-d database name]
NULL
now.how do i do?
January 21, 2013 at 6:28 am
Well if MyXML is already the output you want to pump out to a file, you dont need to exec it, you need to select it as there will be nothing to execute.
Query Out is one word not two, QUERYOUT
Viewing 6 posts - 1 through 6 (of 6 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