Officially, you want to create a database user that is mapped to a login. To do that, you would use:
Create User <username> For LOGIN <loginname>
This obviously requires that the login exist. After that you would then call:
exec sp_addrolemember 'db_owner', <username>
This presumes that the [gs account] with which you are connecting to the database has privileges to add members to the db_owner role.
SOURCE | LINK | LANGUAGE | ENGLISH |
T- SQL to Map User to Database (SQL Server) – http://heelpbook.altervista.org/?p=35863 – 15/02/2013 – 15:05 – HeelpBook – Visit http://www.heelpbook.net OR http://mobile.heelpbook.net on your tablet! @HeelpBook #Heelpbook