Click to See Complete Forum and Search --> : SQL: Testing The Type Of A Variable


RamziAbb
October 26th, 2004, 02:51 PM
Does anyone know how to test the type of a variable in SQL?

Something like

If (TypeOf(@myVariable), varchar) Then
.
.
.


of course TypeOf isn't an SQL function.

Thanks,
Ramzi

panayotisk
October 29th, 2004, 11:31 AM
I think that SQL server variables cannot be of a polymorphic type.
I mean if the cariable is declared as varchar then stays varchar... What do you want to achieve by such a test? There may be some other way out of this.

Davey
October 31st, 2004, 05:56 AM
If you look at INFORMATION_SCHEMA.COLUMNS you can see all your column types.