-
May 20th, 2005, 07:09 AM
#1
SQL Server - How to get the name of the logged in user?
How do I get the name of the user executing a stored proc in the T-SQL in that proc?
e.g.
Code:
ALTER PROCEDURE dbo.TakeOnClient
(
@Id uniqueidentifier
)
AS
DECLARE @Username varchar(200)
-- Get the current login that executes this proc
-- Update the client table
UPDATE dbo.Clients
SET Owner = @Username
WHERE Id = @Id
RETURN
-
May 24th, 2005, 08:48 AM
#2
Re: SQL Server - How to get the name of the logged in user?
how about using this??
Code:
SELECT 'The current user is: '+ convert(char(30), SYSTEM_USER)
-
May 30th, 2005, 06:13 AM
#3
Re: SQL Server - How to get the name of the logged in user?
Or use:
Code:
SET Owner = SUSER_SNAME()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|