How To Create A User With Name Dbo And Loginname KING
Sep 10, 2004How to create a user with name dbo and loginname KING.
So that When I open Users Tab in the database, it should read Name as dbo and lOGIN AS king
How to create a user with name dbo and loginname KING.
So that When I open Users Tab in the database, it should read Name as dbo and lOGIN AS king
I'm trying to automate the creation of a databse and a User/Login but i'm running into problem with a conflict between a new user to which i'm trying to assign a WindowsLogin which is already linked to the dbo. (SQL Server 2005)
Is there a way to reassign the dbo's LoginName to some othe user
Here the code
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'ABC')
BEGIN
declare @cmd nvarchar(max)
set @cmd = 'CREATE USER [ABC] FOR LOGIN ' + @WindowsLogin + ' WITH DEFAULT_SCHEMA=[Shared]'
exec(@cmd)
END
Which give me the error
Msg 15063, Level 16, State 1, Server SR-DEV-GOI1, Line 1
The login already has an account under a different user name.
The script is running under the @WindowsLogin in question !
Thanks All
Gilbert
I have set up roles in my asp.net application, have created my various folders and pages and have the login stuff working nicely, inlcuding displaying the logged-in user's name on screen. What I want to do is read that value (displayed via the LoginName control) as a Parameter in a SqlDataSource query which extracts user-specific data from a sql server 2k datasource. Essentially, if the logged-in user's UserName is jbloggs - I would like to be able to read that into my sql query as @UserName or the like.
If possible, I am trying to do this via the Visual Studio interface, not as code-behind.
Many thanks,
Doc Brown.
How do I pass the user’s LoginName into the WHERE clause of a SQL query?
I created the following query, but I don’t know how to get the user’s LoginName and pass its value into Param1. Nothing I try works.
SELECT property.propertyid, property.shortdesc, property.shortdesclink, property.text, property.UserID, [User].UserID AS Expr1, [User].Name FROM property INNER JOIN [User] ON property.UserID = [User].UserID WHERE ([User].Name = @Param1)
I currently have a LoginStatus and LoginName control on my asp.net 2.0 master page. When successfully logged in a message displays "You are logged in as" LoginName. Since I am using the user's e-mail address as the UserName the message will display as "You are logged in as johndoe@foo.com".
What I want to do is have the message display as "You are logged in as " FirstName LastName. FirstName and LastName are two new fields that I added to the table, aspnet_Users.
What I have done is to use the FormView control to display FirstName and LastName; however this always displays the first record in the aspnetdb database.
Is there a cleaner way (than the FormView control) to display the requested data, using the currently logged in user? I have access to Microsoft Expression Web and Visual Studio 2005, but I prefer Expression Web.
Thank you in advance
I am trying to create a program that user inputs the sa password and it creates a user in SQL Express 2005 installation. Is this possible? If so can someone point me in the right direction?
View 5 Replies View RelatedHello,
I would like to create a new database user using T-Sql command. Somebody Knows?
Thanks,
Hugo Venturini
hi,
i am new to mssqlserver 2005, i installed it successfully in my localhost, problem is i cant create user it gives me:
'my_aro' is not a valid login or you do not have permission
how can i create a user?
In SQL 2005, I want to create a RO_user with read only access rights to some of my databases. I wrote the folloiwng code but get an error in USE @db_name.
Is there an easier way to create the user id and grant the RO access right to it? I have about 500 databases.
USE [Master]
GO
DECLARE @db_name nvarchar(50)
DECLARE db_cursor CURSOR FOR
SELECT master.dbo.[name]
FROM sysdatabases
WHERE Substring(name,1,4) in ('DB06', 'AC06', 'RE07')
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @db_name
WHILE @@FETCH_STATUS = 0
BEGIN
USE @db_name
CREATE USER [RO_user] FOR LOGIN [RO_user]
EXEC sp_addrolemember N'db_datareader', N'RO_user'
FETCH NEXT FROM db_cursor INTO @db_name
END
CLOSE db_cursor
DEALLOCATE db_cursor
Canada DBA
Hello,How can I create a new user with password for the MS SQL - Server 2000(and the MSDE) with a SQL - Statement? I use Borland Delphi 5 with theADO - Components!Thanks.best regards.Stephan Jahrling
View 1 Replies View Relatedhi
im unable to create a new sql server authentication login
It is appreciated if anyone helps me
thanks in advance
Hi,
i'm using SQL server 2005 and I need to create new login/user. Previously I used MySQL where user management is much simplier, so I need a help with SQL server. I run following script:
EXEC sp_addlogin 'uzivatele', @passwd = 'xyz', @defdb = 'master', @deflanguage = 'Czech'
GO
EXEC sp_addsrvrolemember 'uzivatele', 'sysadmin'
GO
GRANT CONNECT SQL TO [uzivatele]
GO
CREATE USER [jirka]
FOR LOGIN [uzivatele]
GO
But when I try to connect o database "master" as user "jirka" with password "xyz", it fails with message "Login failed for user 'jirka'". What do I wrong?
thanks
Jiri Matejka
Hi,
how can i create a user in a stored procedure. the user has to be able to connect to my database
thanks.
Using SQL 6.5 SP4.
TIA.
Zak
i need a scripts which should create a user with dbo privileges on the particular database please help
View 2 Replies View Relatedhello there,
Can i create user forms for user to select options and then present them with data based on their selection.i want to be able to use check boxs and combo box.thanks in advance
cheers
zolf
I have just managed to have JDBC working, but I am getting an error that the user does not exist. I have read in the MSDN help that I need to set the sqlExpress to accept SQL server authentication and not windows authentication. So when I am trying to create a new User using Microsoft SQL server management studio express I get the following error.
TITLE: Microsoft SQL Server Management Studio Express
------------------------------
Create failed for Login 'adam'. (Microsoft.SqlServer.Express.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Login&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
------------------------------
The MUST_CHANGE option is not supported by this version of Microsoft Windows. (Microsoft SQL Server, Error: 15195)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=15195&LinkId=20476
Hello !
I want to create DB users with an stored procedure, and pass the user name as a parameter.
I wrote this code :
CREATE PROCEDURE [dbo].[spTest]
(
@ComName varchar(20),
)
AS
BEGIN
SET NOCOUNT OFF;
CREATE USER [@ComName] WITHOUT LOGIN WITH DEFAULT_SCHEMA = dbo;
END
If I execute this stored procedure :
DECLARE @return_value int
EXEC @return_value = [dbo].[spTest]
@ComName = N'Test_User',
SELECT 'Return Value' = @return_value
I obtain in my DB an user called "@ComNane" instead of "Test_User" !
Where is my mystake ?
Many thanks for any help.
Luc
hello there,
Can i create user forms for user to select options and then present them with data based on their selection.i want to be able to use check boxs and combo box.thanks in advance
cheers
zolf
Hi there,
Can someone please help me how to generate the list of all "user" in a database and it's access role? really need it . .
Thanks
Hi.
I was wondering if I could have a query like this:
CREATE USER 'Firstname Lastname' FOR LOGIN 'DOMAINuser' WITH DEFAULT_SCHEMA=[dbo]
The combination of firstname and lastname does not seem to work.
I have been using:
sp_grantdbaccess 'DOMAINuser', 'Firstname Lastname'
but i cannot specify DEFAULT_SCHEMA with that sp.
Any suggestions?
Hello, After creating a new SSMSExpress Login username account, I
use it as the Database User of the attached database (aspnetdb.mdf), but I
receive this error.... Additional information: ->An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo) ->The login already has an account under a different user name. (Microsoft SQL Server,Error: 15063)...
I am sure such username account is not yet members of that database
(aspnetdb.mdf) for this are the users present-dbo-guest-INFORMATION_SCHEMA-sys-COMPUTERNAMEASPNET-CONPUTERNAMEIUSR_COMPUTERNAME cheers,imperialx
I need to be able to have users run a query under the 'sa' account that will create another account that will just be used for reading and writing to a specific database. Is there a way to do this with just a sql script or can you only set up logins and accounts from the enterprise manager?
View 1 Replies View RelatedHi,
I wonder if anyone can help. I'm trying to create a new user/login to a sql server 2000 box which will automatically have access to all the user databases on the instance. The user can't be a SA or anything however. It seems this can be done as the application which uses all these database has created such a user, however I need another which I will then make read-only.
Any ideas?
Thanks in advance
future2000!
I keep getting an error message "incorrect syntax near keyword case"when trying to run this:USE DEDUPEGOCREATE FUNCTION fnCleanString(@mString varchar (255))RETURNS varchar(255)ASBEGINDECLARE@mChar char(1),@msTemp varchar(255),@miLen int,@i int,@iAsc intBEGINset @mChar = ''set @msTemp = ''set @miLen = Len(@mString)set @i = 1while @i <= @miLenbeginset @mChar = substring(@mString,@i,1)set @iAsc = Ascii(@mChar)casewhen @iAsc >= 87 And iAsc <= 122 Then set @mChar = @mCharwhen iAsc >= 65 And iAsc <= 90 Then set @mChar = @mCharwhen iAsc >= 49 And iAsc <= 57 Then set @mChar = @mCharelse @mChar = ""endset @msTemp = @msTemp & @mCharset @i = @i + 1endENDRETURN @msTempENDCan anybody point out what I'm doing wrong?Thanks.Randy
View 3 Replies View RelatedThis is the error message i keep getting when following the SQL Server tutorial on how to make a new user;
TITLE: Microsoft SQL Server Management Studio Express
------------------------------
Create failed for Login 'employee'. (Microsoft.SqlServer.Express.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Login&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
------------------------------
The MUST_CHANGE option is not supported by this version of Microsoft Windows. (Microsoft SQL Server, Error: 15195)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.2047&EvtSrc=MSSQLServer&EvtID=15195&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
Why is that? Im running XP, do i need to be on 2000 Server or something?
Hello...
Is there any way to create a new database directly as a user instance. I guess this means creating a new mdf/ldf pair which is detached from the server after its created.
Thank you...
Can we able to create a database user name as €˜sa€™ in sql server 2k5?
I have a database for which I need the permissions to execute stored procedures, perform CRUD operations on tables, execute functions and SQL jobs. What should be the SQL command if I am to create a user for this database who will have the most minimum privileges to carry out these activities?
View 4 Replies View RelatedGreetings...
I'm trying to create a user (from certificate):
USE master
GO
CREATE CERTIFICATE UnsafeSample_Certificate
ENCRYPTION BY PASSWORD = 'All you need is love'
WITH SUBJECT = 'Certificate for example_sp',
START_DATE = '20070201', EXPIRY_DATE = '21000101';
BACKUP CERTIFICATE UnsafeSample_Certificate TO FILE = 'C:Documents and SettingsAll UsersDocumentshunterSampleCert.cer'
WITH PRIVATE KEY (FILE = 'C:Documents and SettingsAll UsersDocumentshunterSampleCert.pvk',
ENCRYPTION BY PASSWORD = 'Tomorrow never knows',
DECRYPTION BY PASSWORD = 'All you need is love');
CREATE USER UnsafeSample_Login
FROM CERTIFICATE UnsafeSample_Certificate;
GRANT EXTERNAL ACCESS ASSEMBLY
TO UnsafeSample_Login;
But I'm getting error: "Cannot find the login 'UnsafeSample_Login4', because it does not exist or you do not have permission."
Where i should change rights? User (which i'm using to connect to server) has "sysadmin" server role...
Is it possible to use T-SQL to create a user in Active Directory?
View 7 Replies View RelatedHi all,
I made a Windows forms app using vb.net (VS2005) and SQL server 2005 Express Edition (to which I'm new). During the creation of the app I used windows authentication in the connection string. Now I want to secure the app, meaning I want the SQL Server database not to be accessed without a username/password. I guess the logical thing is to create a login form, providing the username and password so it can be used for connecting to the database. I thought this would be a standard (thus easy) thing to do, but no forum or article yet showed me a way to accomplish this in an understandable way. I also want to deploy this app using click once technology. I need to distribute this app on a cd/dvd.
If possible, can anyone give me a step by step scenario for this? Many thanks in advance
(ps: please let me know if this should be in another thread)
I have a Java application (APP) that use SQL Server 2008 - 20014. In the SQL server there can be more than my database. During setup of the database the first user (ex:ADM) is created using MS SQL Server Management Studio (SMS). ADM can then launch the APP with proper credentials and connect to the database.ADM can then, in the APP, create new users for the APP and database. After some testing for proper CREATE and GRANTS I use the following code to create a new Create, Read, Update, Delete (CRUD) user for the APP and database: CREATE LOGIN testuser WITH PASSWORD='password', DEFAULT_DATABASE = testdb
USE testdb
CREATE USER testuser FOR LOGIN testuser
GRANT AUTHENTICATE TO testuser WITH GRANT OPTION
GRANT CONNECT TO testuser WITH GRANT OPTION
GRANT ALTER ANY USER TO testuser WITH GRANT OPTION
GRANT CONNECT SQL TO testuser WITH GRANT OPTION
GRANT INSERT,SELECT,UPDATE, EXECUTE, DELETE TO testuser WITH GRANT OPTION
USE master
GRANT CONTROL SERVER TO testuser
USE testdb..When I the use the SMS and look at security the "testuser" is only added to testdb. To test I create a second database "testdb2" --> launch the APP to connect to testdb2 and can login with "testuser".I don't know if I give to much grants or missing one...proper TSQL so new users only have CRUD access to "testdb" and no other database on the SQL server.