this is a query
DECLARE @query varchar(8000)
SELECT @query = 'bcp "SELECT a.HospitalName,a.HospitalCode,c.ProductName,
b.UnitsDiscarded,b.DateEntered,b.DateCompleted,b.CompiledBy FROM Ivana_test.dbo.Units b
INNER JOIN Ivana_test.dboHospitals a ON (a.HospitalID = b.HospitalID)
INNER JOIN Ivana_test.dbo.Products c ON (b.ProductID = c.ProductID)
INNER JOIN Ivana_test.dboFateOfProducts d ON (d.FateID = b.FateID)
ORDER BY a.HospitalID" queryout "c:\test.txt" -c -SCenausttrim -Usa -Pcobalt123'
EXEC master.dbo.xp_cmdshell @query
that gives me all the bcp specs as a result
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"]
NULL
and then this query with is just a test query
DECLARE @query NVARCHAR(2000)
SELECT @query = 'bcp "SELECT * from Ivana_test.dbo.Products" queryout c:\test.txt -c -SCenausttrim -Usa -Pcobalt123'
EXEC master.dbo.xp_cmdshell @query
creates a file and everything goes through ok
Could somebody tell me what is the story,can bcp utility support more complex queries.
Thanks
DECLARE @query varchar(8000)
SELECT @query = 'bcp "SELECT a.HospitalName,a.HospitalCode,c.ProductName,
b.UnitsDiscarded,b.DateEntered,b.DateCompleted,b.CompiledBy FROM Ivana_test.dbo.Units b
INNER JOIN Ivana_test.dboHospitals a ON (a.HospitalID = b.HospitalID)
INNER JOIN Ivana_test.dbo.Products c ON (b.ProductID = c.ProductID)
INNER JOIN Ivana_test.dboFateOfProducts d ON (d.FateID = b.FateID)
ORDER BY a.HospitalID" queryout "c:\test.txt" -c -SCenausttrim -Usa -Pcobalt123'
EXEC master.dbo.xp_cmdshell @query
that gives me all the bcp specs as a result
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"]
NULL
and then this query with is just a test query
DECLARE @query NVARCHAR(2000)
SELECT @query = 'bcp "SELECT * from Ivana_test.dbo.Products" queryout c:\test.txt -c -SCenausttrim -Usa -Pcobalt123'
EXEC master.dbo.xp_cmdshell @query
creates a file and everything goes through ok
Could somebody tell me what is the story,can bcp utility support more complex queries.
Thanks