Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SinanP
Starting Member
1 Post |
Posted - 2009-09-25 : 16:16:45
|
| I have a script that creates the database, user, login and the tables.I need databse name to be a variable so i dont need to write it a few times.What I am trying is below, and obviuosly it is wrong.--DATABASE NAMEdeclare @domain varchar(30)set @domain = 'test'declare @db varchar(50)set @db = 'isharedocs_' + @domainPRINT 'Domain name declared'--CREATE USERCREATE LOGIN @dbPASSWORD = 'AndyhAsgoAts'DEFAULT_DATABASE = @db;PRINT 'New Login Created'USE @dbCREATE USER @db FOR LOGIN @dbWITH DEFAULT_SCHEMA = dbo; |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|