June 21, 2006 at 7:10 am
1)I am using print command to display a user and also getdate function but i see result in the same result set, how can i get them in 2 diff columns
2) when i print user iam getting as dbo coz am asigned as admin, how can i get my original id instead of dbo.
June 21, 2006 at 7:20 am
June 21, 2006 at 7:21 am
When I use system_user I get sa id but i need to get windows id.
so do u mean I cant display the result in 2 columns by using print, only select can do that?
June 21, 2006 at 7:24 am
When logging on as SA, there is no matchning LanManName.
N 56°04'39.16"
E 12°55'05.25"
June 21, 2006 at 7:24 am
June 21, 2006 at 7:26 am
June 21, 2006 at 7:27 am
still am getting the result with coma seperated, am not getting in diff columns
but when i use sustem_user am getting as SA, how can i get my user name.
June 21, 2006 at 7:33 am
June 21, 2006 at 7:37 am
my windows user id..under my name.
June 21, 2006 at 7:54 am
there is likely to be way of getting the windows account you are loged onto the network under using T-SQL when you are logged into SQL as SA. Proiler seems to know for example.
But why are you logged in as sa. Why not create a new sql login for your windows account and login under that. the sa account shouldnt really be used except in special circumstances and if you use windows authentication you will be able to the return the current user with system_user...
June 21, 2006 at 8:32 am
PRINT produces a kind of message - a string - rather than a recordset, so it doesn't have columns in the sense of fields. You could mess around with padding your strings and adding crlf characters to the end of a 'line', but you would probably be better off returning a recordset using SELECT, since this is much more flexible, can be passed to applications, is automatically displayed in columns whatever method you choose of displaying it, including in a non-fixed width font, and is THE entity with which just about all SQL is concerned. It incorporates metadata such as datatypes. You definitely need to understand the difference between this and a PRINTed string. Apologies if you already do.
I'm not so sure that you can retrieve the NT user when SQL security is used. No doubt someone knows a way....?
Tim Wilkinson
"If it doesn't work in practice, you're using the wrong theory"
- Immanuel Kant
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply