-George
Microsoft SQL Server MVP My Blogs SQLCop twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
I'm using ifnull as I need to know if 'days to pay' is null set it equal to 30 but then I also need to pull thr value of 'days to pay' if it's anything else also
In T-SQL ISNULL or COALESCE are doing that. Also field names are not delimited by backticks, that's MySQL syntax. In T-SQL you use Schema.TableName.ColumnName, most often dbo for the schema. The column name alone may be sufficient, if it has no spaces. You may also delimit the name parts with [] or ", but not backticks.
Like others have said, IFNULL is not a built-in SQL Server function. ISNULL would work, and Coalesce would also work.
Since you are insistent on using IFNULL, that would indicate to me that you are not using SQL Server or you have a user defined function named IFNULL.
Either way.... I think your problem may be with the single quotes. In SQL Server, you use single quotes to delimit a hard coded string.
IFNULL('daystopay',30)
In this case, you are checking if the string "daystopay" is null. It's a string with a value, so it is not NULL. Try....
IFNULL(daystopay, 30)
Without the single quotes, SQL Server will look for a column named daystopay.
-George
Microsoft SQL Server MVP My Blogs SQLCop twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
Info from here:
[tt]
ISNULL ( a1, a2 )
[/tt]
where a1 is the expression to be checked for NULL and a2 is the expression to be returned if a1 is NULL. If a1 is not null then a1 is returned.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.