I am trying to get the following sp to work:
CREATE PROCEDURE BulkCopy
AS
declare @FileName varchar(100)
declare @string varchar(1000)
SET @filename = 'C:\test'+CONVERT(char(8),GETDATE(),10)+'.txt'
SET @string='bcp "select name, count(recordid) as categorization from
contacts where datetime between (getdate()-7) and (getdate()-1)
group by name order by name" queryout' +@filename +'-c -Sservername -Uusername -Ppassword'
EXEC master..xp_cmdshell @string
GO
when I execute it, I get the following as a result set with no files created:
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
and a list of all the arguments below it.
Can someone help me figure out why this isn't working?
CREATE PROCEDURE BulkCopy
AS
declare @FileName varchar(100)
declare @string varchar(1000)
SET @filename = 'C:\test'+CONVERT(char(8),GETDATE(),10)+'.txt'
SET @string='bcp "select name, count(recordid) as categorization from
contacts where datetime between (getdate()-7) and (getdate()-1)
group by name order by name" queryout' +@filename +'-c -Sservername -Uusername -Ppassword'
EXEC master..xp_cmdshell @string
GO
when I execute it, I get the following as a result set with no files created:
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
and a list of all the arguments below it.
Can someone help me figure out why this isn't working?