all groups > sql server programming > february 2006 >
You're in the

sql server programming

group:

wsid() help


wsid() help rmanchu NO[at]SPAM gmail.com
2/2/2006 10:43:59 PM
sql server programming:
hi

is there a built in function that returns an int that can be set via
the connection string?
wud prefer to use a single function call that returns an int as this
field will be inserted into almost all tables for audit trails.

currently i'm using wsid() but that returns a nchar? would a CAST work
fine?
CAST (WSID() AS INT)

help
riyaz
Re: wsid() help Tibor Karaszi
2/3/2006 12:00:00 AM
WSID() is not a TSQL function, it is implemented in ODBC. The TSQL version is HOST_NAME(). But I
don't recommend you using this, as you would lose supportability, like: "What are the names of the
machines connected to this SQL Server?" This is what the host name attribute is meant for.

How about using SET CONTEXT_INFO for this purpose?

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/


[quoted text, click to view]
Re: wsid() help Tibor Karaszi
2/3/2006 12:00:00 AM
If the host name really contains a number, then yes, you can CAST the value to an int.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/


[quoted text, click to view]
Re: wsid() help rmanchu NO[at]SPAM gmail.com
2/3/2006 12:50:06 AM

but would CAST (HOST_NAME() AS INT) work?

the connection string has "wsid=5". could casting be used as a general
solution to retrieve the number 5 (in conn string)
AddThis Social Bookmark Button