OK, I'm trying to make an "empty" version of a database on another instance of SQL Server 2005. To do this, I use the Scripting wizard to make a big script that CREATEs all the tables, views, SPs, etc., adds some users, and grants permissions for them. Now, in the permission section of the script, I have (among other things)
use [master]
GO
GRANT CREATE VIEW to [myUser]
GO
...
use [prodDb]
GO
GRANT REFERENCES on [tblMyTable] to [myUser]
GO
...
Remember, this is the script generated by the wizard. What I'm trying to figure out is, should the "use master ... GRANT CREATE VIEW" allow myUser to create views in prodDb? That's my understanding -- I'm saying "myUser can create views in any database on this instance" -- but I think I'm getting permission errors when I try to allow myUser to create a view in prodDb. When I look at permissions for prodDb in SQL Server Manager, the permissions are correct, but the target system where I'm executing the generated script doesn't have SQL Server Manager, and I'm not sure how to check per-user permissions on a given object from the command line (and obviously, the errors when I try to exercise those permissions are a big hint).
Is this a bug in the scripting wizard? Should I take away the permissions at Master level and grant them only at the per-DB level? If it makes any difference, this is for a local app on a standalone system that will never be networked.
ETA: OK, so why doesn't the scripting wizard script the correct GRANT statements for prodDb? I mean, if I look at the current permissions for myUser on prodDb, they can CREATE VIEW. But if I run the script on a fresh instance of SQL Server from the command line, myUser cannot CREATE VIEW on prodDb. I can fix this by hand, but it's pretty damn irritating to have to remember that every time I re-run the script wizard.