Thursday, June 18, 2009

TSD03006: User: [username] has an unresolved reference to Login [loginname]

I was getting this error everytime I tired to build my VSTS Database project. The project had been created as a “database project” and not a “server project”.


Because logins are server level objects, they do not get imported as part of the schema into the database project and hence you see the error.

The method that I used (and liked) to solve the problem was to create a 2nd database project which I setup as a “server project”. This one imported login ids and whole lot of other stuff. I then deleted all the other parts that belonged to the project, leaving behind only the login objects.


Finally, I referenced this database project in my main database project.


Voila! and it worked!

Why do I prefer this (over just having a single server project)? because when you create your deployment script – there are 2 scripts created one thats based on the server project and the other based on your database project. In my case, the server project contains all kinds of crap that I typically never need unless I am standing up a new server, so I can ignore it and work only with the main database project.


Anonymous said...

very good work, sometimes i hate database projects ;)

Anonymous said...

Nice, precise doco. Thanks!

Suresh Kalimuthu said...

I want to use te variable reference for login name. How do we delcare the variables for login name?

CREATE USER [$(ReportLogin)] FOR LOGIN [$(ReportLogin)];

Above script i used and defined the variable the sqlcmdvar file. But i am getting the same error

Error 146 SQL03006: User: [$(ReportLogin)] has an unresolved reference to Login [$(ReportLogin)].