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] <rmanchu@gmail.com> wrote in message news:1138949039.893049.38340@o13g2000cwo.googlegroups.com...
>
> 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
>
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] <rmanchu@gmail.com> wrote in message news:1138956606.751482.177260@o13g2000cwo.googlegroups.com...
>
> 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)
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)
Don't see what you're looking for? Try a search.