Sql server查询出错 [英] Error in Sql server query
本文介绍了Sql server查询出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生,
我收到错误
Hi sir,
I am getting the error
"Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '+'.
Msg 319, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon." after executing the below query. Kindly give me the solution for this problem
查询:
--------- -------
Query:
----------------
declare @backuptime varchar(50)
set @backuptime=convert(varchar,getdate())
BACKUP DATABASE checking TO DISK = 'd:\testdb1_'+@backuptime+'.bak' WITH FORMAT, MEDIANAME = 'checking', NAME = 'Full backup of my database';
GO
推荐答案
尝试更改此内容;
Try changing this;
declare @backuptime varchar(50)
set @backuptime=convert(varchar,getdate())
BACKUP DATABASE checking TO DISK = 'd:\testdb1_'+@backuptime+'.bak' WITH FORMAT, MEDIANAME = 'checking', NAME = 'Full backup of my database';
GO
到此;
to this;
declare @backuptime varchar(50)
set @backuptime=convert(varchar,getdate())
declare @path nvarchar(1024)
set @path='d:\testdb1_'+@backuptime+'.bak'
BACKUP DATABASE checking TO DISK = @path WITH FORMAT, MEDIANAME = 'checking', NAME = 'Full backup of my database';
GO
希望这会有所帮助,
Fredrik
Hope this helps,
Fredrik
这篇关于Sql server查询出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文