ALTER PROCEDURE [Company].[Create_New_DataBase]
(@bd_name varchar(50),
@SchmaName VARCHAR(255),
@CompanyName VARCHAR(255))
as
BEGIN
IF NOT EXISTS(SELECT database_id FROM sys.databases WHERE name =@bd_name)
BEGIN
EXEC('Create DATABASE'+' '+ @bd_Name)
BEGIN
EXEC('USE'+' '+ @bd_Name)
EXEC('SELECT * INTO '+@bd_Name+'.'+@SchmaName+'.Banner FROM BlueBubble.Contents.Banner
where CompanyName='+@CompanyName)
end
end
else
print 'This Data base Is allready Existing'
end
No comments:
Post a Comment