Link to home
Start Free TrialLog in
Avatar of johnhardy
johnhardyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Usernames and passwords for MS SQL

I am using MS SQL 2008 express on my local machine XP
I can connect to MS SQL databases using windows authentication but some software I wish to use requires a username and password
server=SERVERNAME;uid=USERNAME;pwd=PASSWORD;database=DATABASE_NAME

Can anyone advise how I create the username and password please?
Servername and databse names are known.
Many thanks
John hardy
Avatar of Som Tripathi
Som Tripathi
Flag of India image

You may use below t-sql statement -

CREATE LOGIN login_name WITH PASSWORD='password'
GO
USE DATABASE_NAME
GO
--Creating User - user_name .. Login and user_name is mostly the same --
CREATE USER user_name FROM login_name
GO
--Also you might need to grant some roles - such as dbo (db_owner), datareader (db_datareader) or datawriter (db_datawriter)--

USE DATABASE_NAME
GO
exec sp_addrolemember 'db_owner' , 'user_name'
GO

You can also just create that user in Management Studio (SSMS) under "Security", if you prefere the GUI approach.
Avatar of johnhardy

ASKER

Thanks for the info
I created a login via the GUI but the login fails as image.
Being new to MS SQL I regret I dont know about t-sql statements.
 User generated image
What is the password for sa?
The sa password is defined when installing MSSQL Express. It might be empty, but I don't think so.
SOLUTION
Avatar of Bhavesh Shah
Bhavesh Shah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi,

if you doing for your own use then below link currently wont require.

if you trying to create multiple users with different role then check out following link.

https://www.experts-exchange.com/questions/26532011/Is-there-a-way-to-create-new-user-into-sql-server.html?sfQueryTermInfo=1+10+30+brichsoft+creat+login
Thanks,
I revised the sa password as suggested by Brichsoft but get the fail error message.
 User generated image
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You will need to enable the sa account under Security.
This completed the puzzle so thanks for all of the help.
Many thanks
John