Use database dynamically

Posted by Redi on Stack Overflow See other posts from Stack Overflow or by Redi
Published on 2010-04-14T09:02:43Z Indexed on 2010/04/14 9:33 UTC
Read the original article Hit count: 214

Filed under:
|
|
|

This execution it is giving me an error!

Any hints of what am I missing?

declare @dbname varchar(500)
set @dbname='master'
Exec ('

Use ' + @dbname + '

go

create PROCEDURE [dbo].[krijo_database] @dbname nvarchar(2000), @Direktoria varchar(4000)
AS
BEGIN
    declare @stringu nvarchar(100)
    set @stringu = 
    ''CREATE DATABASE '' + @dbname 
    exec (@stringu)
End
')

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql