December 20, 2009 at 11:53 pm
Dear Sir,
I am tring to create database use store procedure through input parameter. but it give syntax error
I can't under standad why it is giving syntax erro.
This is my code below
CREATE PROCEDURE sh_CreateDataBase
@tmpDb as Char(15),--input parameter for creating database
@tmpPath as VarChar(50)--input parameter for giving path or folder where database is created
As
CREATE DATABASE @tmpDb
ON PRIMARY
(NAME=@tmpDb + '_dat',
FILENAME=@tmpPath+'\'+tmpDb+'.mdf',
SIZE=10MB,
MAXSIZE=100MB,
FILEGROWTH=10%)
LOG ON
(NAME=@tmbpDb+'_log',
FILENAME=@tmpPath+'\'+tmpDb+'.ldf',
SIZE=5MB,
MAXSIZE=20MB,
FILEGROWTH=5%)
Server: Msg 170, Level 15, State 1, Procedure sh_CreateDataBase, Line 6
Line 6: Incorrect syntax near '@tmpDb'.
December 21, 2009 at 12:13 am
CREATE DATABASE statement does not accept variables. You can try dynamic query instead. Check these links:
http://www.umachandar.com/technical/sql6x70scripts/UtilitySPs(6x)/Main9.htm
http://www.databasejournal.com/scripts/article.php/1546441/spcreatedatabaseSQL.htm
Satish
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply