Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql session or connection ... is there anything like that? 1

Status
Not open for further replies.

iamsw00sh

Programmer
Joined
May 21, 2003
Messages
92
Location
RO
case:
Johnny boy is logged on to my site from his home computer
he is saving data let`s say in "Invoice" table

Thomas boy is loged on to my site too ... ok?
he is also saving data in "Invoice" table

is there a way from SQL server to make a difference(Thomas VS. Johnny)?
like without using ASP, or Coldfusion or whatever ...
only from SQL ...
is it possible?

I would like to get some kind of variable ...
something like the IP for example but i don`t exactly need the IP
some variable that depends on `Connection` maybe ...

is this case a lost one?
 
How is Johnny boy and Thomas boy connecting to the SQL server? i.e. ASP/ADO or ISQL remote host etc.
 
Check out
SESSION_USER
CURRENT_USER
SYSTEM_USER
USER_NAME

Maybe these functions will help. If they are coming in from a website and all use the same connection values to login, you will have a more difiicult time defining who is connected. What we do is have the application collect the IP address and then send it to a stored procedure which then stores it in a table.

Our site also requires a login, so we can track who made a change using their user id stored in our user table and held in session by the application. You could do something similar with IP addresses. Have the application get the IP address and keep it in the session and then every insert, or update send that as one of the variables to the database to put in an audit field of IpAddress which you put in every table.
 
Refer to the Books OnLine and check out SUSER_SNAME.

Create a new column in the table, called UpdatedBy or something like that.

Create a trigger for inserts, that pulls the data from SUSER_SNAME and inserts it into UpdatedBy along with the rest of the INSERT data.

-SQLBill
 
i think SQLBill helped me ... i need to check ...

i think this is gonna be marked as a helpful/expert post ... :-)

thanks guys .. i am looking for this for a while now ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top