SQL语句的错误,请高手帮忙看看
EXEC master..xp_cmdshell 'bcp "select * from casinodb.dbo.chipin_record where datediff(d,chipin_time,getdate())> =1 " queryout d:\ ' + convert(varchar(10),GetDate(),120) + '.txt -c -U sa -P zjx1551 '
上面的这句话有什么错误吗?为什么老提示如下的错误呀,还请高手们帮我看看
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '+ '.
------解决方案--------------------declare @sql varchar(1000)
set @sql = 'bcp "select * from casinodb.dbo.chipin_record where datediff(d,chipin_time,getdate())> =1 " queryout d:\ ' + convert(varchar(10),GetDate(),120) + '.txt -c -U sa -P zjx1551 '
EXEC master..xp_cmdshell @sql
------解决方案--------------------SQL code
declare @sql varchar(1000)
set @sql ='bcp "select * from casinodb.dbo.chipin_record where datediff(d,chipin_time,getdate()) >= 1" queryout "d:\'
+ convert(varchar(10),GetDate(),120) + '.txt" -c -U sa -P zjx1551'
exec master..xp_cmdshell @sql
------解决方案--------------------
declare @sql varchar(1000)
set @sql ='bcp "select * from casinodb.dbo.chipin_record where datediff(d,chipin_time,getdate()) >= 1" queryout "d:\'
+ convert(varchar(10),GetDate(),120) + '.txt" -c -U sa -P zjx1551'
exec master..xp_cmdshell @sql