1
我想創建一組數據庫(數據庫名稱應該從一個數據庫中的表(在同一個實例中)按增量順序挑選)。任何人都可以幫助我如何做到這一點?SQL Server數據庫組創建腳本
DECLARE @loopcounter INT = 1, @Maxid INT = 100, @zid nvarchar(100)
WHILE(@LoopCounter <= @Maxid)
BEGIN
SELECT @zid = zids
FROM dbo.list_zid WHERE id = @LoopCounter
SET @LoopCounter = @LoopCounter + 1
print @zid
end
DECLARE @DBNAME VARCHAR(50)
SET @DBNAME = '@zid'
CREATE DATABASE @DBNAME
GO
ALTER DATABASE @DBNAME SET COMPATIBILITY_LEVEL = 90
GO
ALTER DATABASE @DBNAME SET RECOVERY SIMPLE
GO