Jimby_Aus
asked on
Exec Create Database Statement with TSql Variable and Text Qualifiers
My question is fairly straight forward, im trying to Exec an SQL statement that will create a new database, however I want to retrieve the database path from a storedprocedure and use a variable. Along the lines of
DECLARE @dbpath nvarchar(255)
DECLARE @sql nvarchar(1000)
EXEC spsqldatabasepath @dbpath
Set @sql = 'CREATE DATABASE [dbname] ON (NAME = N'dbame.mdf', FILENAME = '+@dbpath , etc...
EXEC(@sql)
However the FILENAME clause is supposed to also have a text qualifer around it within the sql statement, how do I handle all the ' qualifiers ' and build the sql string?
DECLARE @dbpath nvarchar(255)
DECLARE @sql nvarchar(1000)
EXEC spsqldatabasepath @dbpath
Set @sql = 'CREATE DATABASE [dbname] ON (NAME = N'dbame.mdf', FILENAME = '+@dbpath , etc...
EXEC(@sql)
However the FILENAME clause is supposed to also have a text qualifer around it within the sql statement, how do I handle all the ' qualifiers ' and build the sql string?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER