July 31, 2013 at 9:34 am
Hi Team,
how to create a new user with Password
User Name : STLOK
Password : STLOK
and it should be read - only user.
July 31, 2013 at 10:09 am
Minnu (7/31/2013)
Hi Team,how to create a new user with Password
User Name : STLOK
Password : STLOK
and it should be read - only user.
http://msdn.microsoft.com/en-us/library/ms173463.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 31, 2013 at 11:08 am
a basic example:
Create LOGIN [ClarkKent] WITH PASSWORD='NotTheRealPassword'
USE [WHATEVER]
Create USER [ClarkKent] FOR LOGIN [ClarkKent]
CREATE ROLE [ReadOnlyRole]
EXEC sp_addrolemember N'db_datareader', N'ReadOnlyRole'
--can the users EXECUTE procedures? comment out if false
GRANT EXECUTE TO [ReadOnlyRole]
--allow the users to see view proc and function definitions? comment out if false
Grant View Definition ON SCHEMA::[dbo] To [ReadOnlyRole]
--finally add our user to the role:
EXEC sp_addrolemember N'ReadOnlyRole', N'ClarkKent'
--test:
EXECUTE AS USER='ClarkKent'
--who am i?
select suser_name()
--do stuff
--change back into superman
REVERT;
--clean up after ourselves
/*
DROP ROLE [ReadOnlyRole]
DROP USER [ClarkKent]
DROP LOGIN [ClarkKent]
*/
Lowell
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply