Hi, I have written the following procedure to create a series of 20 databases. But it is not creating them. The database is not created even when I go to my H: drive and didnot find the ldf and mdf named bharath1 bharath2 like...
What did I do wrong with this?
USE master
GO
DECLARE @command varchar(1000), @i int
while @i < 5
SET @command = 'CREATE DATABASE Bharath' + CAST(@i AS varchar) + '
ON ( NAME = ''Bharath_dat'',
FILENAME = ''H:\MSSQL10.MSSQLSERVER\MSSQL10.MSSQLSERVER\MSSQL\DATA\Bharath' +
CAST(@i AS varchar) + '.mdf'', SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5 )
LOG ON ( NAME = ''Bharath_log'',
FILENAME = ''H:\MSSQL10.MSSQLSERVER\MSSQL10.MSSQLSERVER\MSSQL\DATA\Bharath' +
CAST(@i AS varchar) + '.ldf'', SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB )'
EXEC (@command)
SET @i = @i + 1
GO
I don't have any idea in SQL Server stored procedure as of my knowledge and with somebody support i did like this. But i am not finding any databases.
Any help greatly appreciated.