From: cj2 on
Why doesn't this work? In real life this will be the start of a sql
report and the value of @AlertId will change. It could be 'ALL' or an
integer. I need to actually see 'ALL' as -1.



declare @AlertId as char
set @AlertId = 'ALL'

declare @AlertId2 as int
if @AlertId = 'ALL'
set @AlertId2=-1
else
set @AlertId2 = @AlertId
From: cj2 on
This is another attempt but it doesn't work quite right either. It
fails to correctly pass the number in @AlertId to @AlertId when @AlertId
is a number. All it gives me is 2.

declare @AlertId as char
set @AlertId = '252525'

declare @AlertId2 as bigint

if ISNUMERIC(@AlertId) = 1
set @AlertId2 = @AlertId
else
set @AlertId2 = -1

select @AlertId2



On 5/5/2010 3:55 PM, cj2 wrote:
> Why doesn't this work? In real life this will be the start of a sql
> report and the value of @AlertId will change. It could be 'ALL' or an
> integer. I need to actually see 'ALL' as -1.
>
>
>
> declare @AlertId as char
> set @AlertId = 'ALL'
>
> declare @AlertId2 as int
> if @AlertId = 'ALL'
> set @AlertId2=-1
> else
> set @AlertId2 = @AlertId
From: Scott Morris on
> declare @AlertId as char

This is the same as: declare @AlertId as char(1)

Now does it seem more obvious?


From: cj2 on
yes, Thanks!

On 5/5/2010 4:26 PM, Scott Morris wrote:
>> declare @AlertId as char
>
> This is the same as: declare @AlertId as char(1)
>
> Now does it seem more obvious?
>
>
From: cj2 on
Yes. Thanks! I got it working.

On 5/5/2010 4:26 PM, Scott Morris wrote:
>> declare @AlertId as char
>
> This is the same as: declare @AlertId as char(1)
>
> Now does it seem more obvious?
>
>