Re: Is it possible to create a custom SQL session function/variable



Take a look at SET CONTEXT_INFO in the Books Online. That allows you to set a value for the connection that is accessible anywhere in the session with the CONTEXT_INFO function. Since the value is binary, you'll need to convert as needed.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"GMG" <gmgsoftware@xxxxxxxxxxxxx> wrote in message news:%23cNc2ceuHHA.3376@xxxxxxxxxxxxxxxxxxxxxxx
To avoid having to pass this user specific ID via a parameter in the stored
procedure, is it possible to create your own function like (like
suser_sid()) or variable (like @@SPID) ?

This value would be passed from a Web Service (asp.net 2.0) in the
connection string or something and could be referred to anywhere in the SQL
code (SQL 2005).

Has anyone got a better solution than a SP parameter ?



.



Relevant Pages

  • Re: sys.dm_exec_connections, sys.dm_exec_sessions and sys.dm_exec_requests
    ... executing within SQL Server ... connection till the connection is disconnected and reconnected. ... The sys.dm_exec_sessions returns data about session information for the ... The sys.dm_exec_requests returns data about the sql that is being ...
    (microsoft.public.sqlserver.server)
  • Re: IDENTITY_INSERT error
    ... > "Val Mazur" wrote: ... >> Session means same opened connection. ... >> your command opens another connection and you could check it using SQL ... >>> same "session" as the insert statement. ...
    (microsoft.public.data.ado)
  • Re: Session state lost after accessing database
    ... updates values in the session state and executes a SQL statement while the ... >>I have an ASP.NET application that connects to an Access database. ... >>The second button creates a connection to the database, executes a SQL ... Connection is a OledbConnection connecting via OLEDB JET. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IDENTITY_INSERT error
    ... the same connection, just a different ADODB.Command. ... > Session means same opened connection. ... What you could do is (if you are using OLEDB Provider for SQL ... > Server) is to execute both statement in one batch separating them by ...
    (microsoft.public.data.ado)
  • Re: How to check if SQL Server is local or remote
    ... Server. ... understand if the connection points to a local SQL Server or a remote SQL ... Books Online for SQL Server 2005 at ...
    (microsoft.public.data.oledb)