0

I have a program where I need to create a user through SQL and give them access to a database. This program is run against SQL Server 2000. I could have sworn the SQL was working when I wrapped up at the end of the day yesterday but it's not working today and I'm pulling my hair out trying to make it work.

use master
exec sp_addlogin @loginame='newLogin', @passwd='password', @defdb='theDB'
use theDB
exec sp_grantdbaccess newLogin, newLogin
grant all to newLogin

After running the SQL statements as "sa" I log in as the new user and try to select from any of the tables in the database and get

SELECT permission denied on object 'XXXX', database 'YYYY', owner 'dbo'

What am I missing?

4

1 に答える 1