G
Guest
Hello,
I have a table
CREATE TABLE [dbo].[RequestedServices] (
[ServiceID] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[FollowUpID] [int] NULL
) ON [PRIMARY]
and a query
Select Name, FollowUpID from RequestedServices
but I would like to add a boolean computed column to the query called "Completed" which is true if FollowUpID is not null and false if FollowUpID is null. How would I do this? I attempted
Select Name, FollowUpID, (FollowUpID is null) AS Completed from RequestedServices
but it didn't work. I got it working by setting up a User Defined Function
Select Name, FollowUpID, dbo.IsColumnNull(FollowUpID) AS Completed from RequestedServices
but it would be much easier if I could include the logic in the Select statement without resorting to outside functions. Thanks for your help!
I have a table
CREATE TABLE [dbo].[RequestedServices] (
[ServiceID] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[FollowUpID] [int] NULL
) ON [PRIMARY]
and a query
Select Name, FollowUpID from RequestedServices
but I would like to add a boolean computed column to the query called "Completed" which is true if FollowUpID is not null and false if FollowUpID is null. How would I do this? I attempted
Select Name, FollowUpID, (FollowUpID is null) AS Completed from RequestedServices
but it didn't work. I got it working by setting up a User Defined Function
Select Name, FollowUpID, dbo.IsColumnNull(FollowUpID) AS Completed from RequestedServices
but it would be much easier if I could include the logic in the Select statement without resorting to outside functions. Thanks for your help!