Posted by Jack Vamvas on 10/16/11 11:37
Take out the GO comments
--
Jack Vamvas
__________________________________________________________________
Receive free SQL tips - register at www.ciquery.com/remotedba.htm
SQL Server Performance Audit - check www.ciquery.com/sqlserver_audit.htm
New article by Jack Vamvas - SQL and Markov Chains -
www.ciquery.com/articles/art_04.asp
"Cecil" <cecilkain0@yahoo.com> wrote in message
news:1137514452.848879.303200@g47g2000cwa.googlegroups.com...
> I get this error:
> Msg 137, Level 15, State 2, Line 2
> Must declare the scalar variable "@DBName".
>
>
> W/ this code:
>
> --Constants
> DECLARE @DBName varchar(20);
> SET @DBName = 'Base';
> GO
>
>
> --Create & Use Database @DBName
> USE master
> GO
>
> if exists (select * from sysdatabases where name=@DBName)
> drop database @DBName
> GO
>
> CREATE DATABASE @DBName
> GO
> use @DBName
> GO
>
> How should this be done?
>
Navigation:
[Reply to this message]
|