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
 General SQL Server Forums
 New to SQL Server Programming
 User has an unresolved reference to Login

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2010-10-16 : 19:40:11
Hello,

I have the following script to recreate a Login, User and Role:

-- Set context
use master
go

-- Delete login
if exists (select * from sys.server_principals where name = N'DBTest')
drop login DBTest
go

-- Create login
create login DBTest
with password = 'fop62822022',
check_policy = off,
check_expiration = off,
default_database = DBTest,
default_language = english;
go


-- Set context
use DBTest
go

-- Delete user
if exists (select name from sys.database_principals where name = N'DBTest')
drop user DBTest
go

-- Delete role
if exists (select * from sys.database_principals where name = N'Application' and type = 'R')
drop role [Application]
go

-- Create user
create user DBTest;
go

-- Create role
create role [Application];
go

-- Grant permissions to role
grant select, insert, update, delete, execute on schema::dbo to [Application];

-- Associate user to role
exec sp_addrolemember @membername = N'DBTest', @rolename = N'Application';
go

But when recreating this project using the new VS 2010 Database projects I get the following error:

Error 1: SQL03006: User: [DBTest] has an unresolved reference to Login [DBTest].

What am I doing wrong?

Thank You,

Miguel

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-16 : 23:39:02
What happens if you run it in Management Studio?

Visual Studio supports limited SQL statements, so it is not a good tool to use for DBA-type scripts such as yours.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -