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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 DB Install Script

Author  Topic 

JesseSQL
Starting Member

1 Post

Posted - 2008-09-02 : 00:47:18
Hi guys,

I'm trying to create a database install script which has exclusive rights to the user it creates, and denies access to windows authentication:


Create Database DB_NAME;
GO
USE [DB_NAME]
GO
CREATE LOGIN [logDB_NAME] WITH PASSWORD='password', DEFAULT_DATABASE=[DB_NAME], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON
GO
CREATE USER [usrDB_NAME] FOR LOGIN [logDB_NAME] WITH DEFAULT_SCHEMA=[db_owner]
GO
ALTER AUTHORIZATION ON SCHEMA::[db_owner] TO [usrDB_NAME]
GO
EXEC sp_addrolemember N'db_securityadmin', N'usrDB_NAME'
GO
EXEC sp_addrolemember N'db_owner', N'usrDB_NAME'
GO

...Create Tables...

EXEC sp_changedbowner 'usrDB_NAME', False


I seem to have the opposite effect though, windows authentication is fine with full access but none to the logDB_NAME login...

Thanks,
Jesse
   

- Advertisement -