September 3, 2009 at 5:03 am
Hello everyone,
how can I display something when a specific field value is not null ?
That of course wont work:
SELECT *, ISNOTNULL(Authordate,'Last Upload: ') + ISNULL(Authordate,'') From Documents
Any suggestions ?
Sascha
September 3, 2009 at 5:31 am
SELECT < Column list >,
CASE WHEN AuthorDate IS NULL THEN '' ELSE 'Last Upload: ' + CONVERT(VARCHAR(30), AuthorDate, < Appropriate formatting code >) END
FROM Documents
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 3, 2009 at 7:21 am
Same principal different code provided CONCAT_NULL_YIELDS_NULL is ON.
SELECT ISNULL('Last Upload: ' + CONVERT(VARCHAR, AuthorDate+'', 112), '')
FROM Documents
Dave
September 5, 2009 at 1:43 am
Thank you both for your fast help, justanewone i used your solution its works fine ! 🙂
Sascha
September 5, 2009 at 9:49 am
how can I display something when a specific field value is not null ?
I see the examples of code folks gave you but they aren't really required. If the field is NOT null, it will display... no? Most systems will display a NULL as a blank and don't require a conversion to a blank or empty string. You'll save clock cycles in the process. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply