SQL存储过程,这个字符串怎么拼接哈?菜鸟求助.
ALTER PROCEDURE USP_DBBackup
@BackPath nvarchar(100)
@BackName nvarchar(50)
AS
SET NOCOUNT ON
declare cur cursor for
select name from master..SysDataBases--获取数据库名.
declare @cur nvarchar(4000)
open cur
fetch next from cur into @cur
while @@fetch_status = 0
begin
exec(@cur)
fetch next from cur into @cur
end
declare @name nvarchar(4000)
set @name = ''
select @name += @cur + ','
backup database Left(@name, Len(@name) - 1) to disk= @BackPath + '\'+@BackName--备份以上获得的数据库.
alter PROCEDURE USP_DBBackup
@BackPath nvarchar(100),
@BackName nvarchar(50)
AS
SET NOCOUNT ON
declare @name nvarchar(4000)
select @name = rtrim(ltrim(@name))
if exists (select * from sysdatabases where name = 'YJUIDB')
set @name= 'YJUIDB'
declare @outpath nvarchar(4000)
select @outpath = @BackPath +'\'+ @BackName
backup database @name to disk= @outpath