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
 how do i create a new user in a db via t-sql

Author  Topic 

zubair
Yak Posting Veteran

67 Posts

Posted - 2009-01-26 : 09:07:46
I am trying to use the following command:

use bungi;
CREATE USER sqlbungi FOR LOGIN sqlbungi;

However i am getting the following error:

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'USER'.

Can anyone tell me why and what the correct cmmands are then?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-26 : 09:09:40
http://msdn.microsoft.com/en-us/library/ms173463(SQL.90).aspx
Go to Top of Page

zubair
Yak Posting Veteran

67 Posts

Posted - 2009-01-26 : 09:59:03
thx but I have already visited this page and this is where I got the commands above... the create user command doesn't work...

I am using the version 8.00.2039
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-26 : 10:04:04
You need to use sp_adduser in SQL 2000.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-26 : 10:06:58
have you created login before executing this?
Go to Top of Page

JamesRyan
Starting Member

18 Posts

Posted - 2009-01-26 : 12:19:36
http://itknowledgeexchange.techtarget.com/itanswers/creating-a-user-in-sql-server-2000/



James Ryan
www.sqlhowto.co.uk
Go to Top of Page

zubair
Yak Posting Veteran

67 Posts

Posted - 2009-01-26 : 16:08:16
Thanks!
Go to Top of Page

Rajesh Jonnalagadda
Starting Member

45 Posts

Posted - 2009-01-28 : 07:45:54
Try this,
CREATE LOGIN [Test] WITH PASSWORD=N'TestTest', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=ON
GO
EXEC sys.sp_addsrvrolemember @loginame = N'TEST', @rolename = N'sysadmin'

OR

CREATE LOGIN [BUILTIN\Administrators] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]


Rajesh Jonnalagadda
[url="http://www.ggktech.com
"]GGK TECH[/url]
Go to Top of Page
   

- Advertisement -