alter proc SPcreater(@strs nvarchar(max)
)
as begin
DECLARE @ID varchar(50)
DECLARE c CURSOR READ_ONLY FAST_FORWARD FOR
SELECT name
FROM master..sysdatabases where name like 'iclaim%' and name !='iclaim'
-- Open the cursor
OPEN c
FETCH NEXT FROM c INTO @id
WHILE (@@FETCH_STATUS = 0)
BEGIN
DECLARE @command varchar(max)
SELECT @command = 'USE '+ @id +''
SET @command=@command+'
Go'
Set @command =@command +@strs
SET @command=@command+'
GO
'
print @command
FETCH NEXT FROM c INTO @id
END
-- Close and deallocate the cursor
CLOSE c
DEALLOCATE c
end
No comments :
Post a Comment