Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 New to sql server

Author  Topic 

007Panther
Starting Member

2 Posts

Posted - 2008-08-25 : 13:39:16
I tried to find something similar in the list but was unable to. What I need help on is probably simple.
I get an error message:Syntax error converting the varchar value 'NULL' to a column of data type int.

field it's yelling at is: my parameter: @Phase varchar(5) in my create table: Phase int, in my select statement I have: isnull(c.phase,0), and in my where clause: (@Phase = 'All' or isnull(@Phase,'0') = convert(varchar(10),isnull(c.phase,0)))
I thought this would work but it's not can someone assist please?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-25 : 13:40:46
Please post the actual query that is throwing the error.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-25 : 13:43:14
its not working as you've string 'NULL' value existing in your phase field. 'NULL' and NULL are different. isnull captures only latter. try below and see if it works

(@Phase = 'All' or isnull(NULLIF(@Phase,'NULL'),'0') = convert(varchar(10),isnull(c.phase,0)))
Go to Top of Page

007Panther
Starting Member

2 Posts

Posted - 2008-08-25 : 13:53:55
I found the issue thank you both for your quick reply.
Go to Top of Page
   

- Advertisement -