Have a table with one Text field. I used it to store a whole script for creating a DataBase, becuase a Script is very long (more than 120K) how could I execute it w/o using several variables? Is there a way to execute it. I want this because the name of the DB is different each time and I must USE that DB before create all tables and other objects in?
All this is in a SP create in other DB
Something like:
TIA
Borislav Borissov
All this is in a SP create in other DB
Something like:
Code:
USE MyMainDB
EXEC CreateNewDB 1
--- SP code
CREATE PROCEDURE CreateNewDB(@DataBaseID as int)
AS
BEGIN
DECLARE @DataBaseName varchar(50)
SET @DataBaseName = [NewFirmDB]+RIGHT('0000'+cast(@DataBaseID as varchar(4)),4)
EXEC ('CREATE DATABASE '+@DataBaseName)
--- Here comes the trouble
---
EXEC ('USE '+@DataBaseName+';'+Contents of that field)
END
Borislav Borissov