帮忙看看错在什么地方!?谢谢各位

rock198217 2004-09-01 10:34:58
use master
go
declare @getday varchar(50)
select @getday = convert(varchar(20),getdate(),112)
if exists (select * from dbo.sysdevices where name = object_name(N'@getday'))
sp_dropdevice @getday


想在创建设备前,前差系统中是否存在此设备,如果存在,删除,不存在则创建该设备。
设备的命名规则为yyyymmdd,然后备份数据库到该设备
...全文
107 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhushizu 2004-09-01
  • 打赏
  • 举报
回复
是呀,我也是想了好久。。关注中。。。
rock198217 2004-09-01
  • 打赏
  • 举报
回复
use master
go
declare @getday varchar(50),@path varchar(50)
select @getday = convert(varchar(20),getdate(),112)
select @path = 'd:\bak\' + @getday + '.bak'
if exists (select * from dbo.sysdevices where name=@getday)
exec sp_dropdevice @getday
exec sp_addumpdevice 'disk',@getday ,@path


我自己找到了这个方法写,好像更容易理解些!不过还是要谢谢你热心帮助我!
pbsql 2004-09-01
  • 打赏
  • 举报
回复
use master
go
declare @getday varchar(50),@path varchar(50)
select @getday = convert(varchar(20),getdate(),112)
select @path = 'd:\bak\' + @getday + '.bak'
if exists (select * from dbo.sysdevices where name=@getday)
exec('sp_dropdevice '+@getday)
exec('sp_addumpdevice ''disk'','''+@getday+''','+''''+@path+'''')
rock198217 2004-09-01
  • 打赏
  • 举报
回复
use master
go
declare @getday varchar(50),@path varchar(50)
select @getday = convert(varchar(20),getdate(),112)
select @path = 'd:\bak' + @getday + '.bak'
if exists (select * from dbo.sysdevices where name=@getday)
exec('sp_dropdevice '+@getday)
exec('sp_addumpdevice' +'disk' + @getday +@path)



这里又是什么地方错了!?
pbsql 2004-09-01
  • 打赏
  • 举报
回复
use master
go
declare @getday varchar(50)
select @getday = convert(varchar(20),getdate(),112)
if exists (select * from dbo.sysdevices where name=@getday)
exec('sp_dropdevice '+@getday)
futulove 2004-09-01
  • 打赏
  • 举报
回复
+@getday+
试试

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧