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! 7 944
Select Name, FollowUpID,
-- return 1 for true and 0 for false.
case isnull(FollowUpID,'a' )
when 'a' then 0
else 1
end as Completed
from RequestedServices
Is this what you want?
"Solel Software" <So***********@newsgroup.nospam> wrote in message
news:40**********************************@microsof t.com... 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!
You're more likely to get responses for this kind of question in a SQL
newsgroup, but I believe the solution would be this:
Select Name, FollowUpID, IsNull(FollowUpID,0,1) AS Completed from
RequestedServices
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Solel Software" <So***********@newsgroup.nospam> wrote in message
news:40**********************************@microsof t.com... 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!
Correction, this syntax is more accurate:
Select Name, FollowUpID, IsNull(FollowUpID,0) AS Completed from
RequestedServices
This will return a zero if it's null, otherwise it will return the
FollowUpID.
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl... You're more likely to get responses for this kind of question in a SQL newsgroup, but I believe the solution would be this:
Select Name, FollowUpID, IsNull(FollowUpID,0,1) AS Completed from RequestedServices
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Solel Software" <So***********@newsgroup.nospam> wrote in message news:40**********************************@microsof t.com... 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!
Darren,
This is exactly what I was looking for! Thank you so much! It's perfect.
"Darren Clark" wrote: Select Name, FollowUpID, -- return 1 for true and 0 for false. case isnull(FollowUpID,'a' ) when 'a' then 0 else 1 end as Completed
from RequestedServices
Is this what you want?
"Solel Software" <So***********@newsgroup.nospam> wrote in message news:40**********************************@microsof t.com... 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!
Darren,
This is exactly what I was looking for! Thank you so much! It's perfect.
"Darren Clark" wrote: Select Name, FollowUpID, -- return 1 for true and 0 for false. case isnull(FollowUpID,'a' ) when 'a' then 0 else 1 end as Completed
from RequestedServices
Is this what you want?
"Solel Software" <So***********@newsgroup.nospam> wrote in message news:40**********************************@microsof t.com... 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!
Steve,
Darren's reply actually uses this method in combination with Case to achieve a boolean column.
"Steve C. Orr [MVP, MCSD]" wrote: Correction, this syntax is more accurate: Select Name, FollowUpID, IsNull(FollowUpID,0) AS Completed from RequestedServices
This will return a zero if it's null, otherwise it will return the FollowUpID.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net "Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message news:Oq**************@TK2MSFTNGP10.phx.gbl... You're more likely to get responses for this kind of question in a SQL newsgroup, but I believe the solution would be this:
Select Name, FollowUpID, IsNull(FollowUpID,0,1) AS Completed from RequestedServices
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Solel Software" <So***********@newsgroup.nospam> wrote in message news:40**********************************@microsof t.com... 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!
Darren,
This is exactly what I was looking for! Thank you so much! It's perfect.
"Darren Clark" wrote: Select Name, FollowUpID, -- return 1 for true and 0 for false. case isnull(FollowUpID,'a' ) when 'a' then 0 else 1 end as Completed
from RequestedServices
Is this what you want?
"Solel Software" <So***********@newsgroup.nospam> wrote in message news:40**********************************@microsof t.com... 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! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: aaj |
last post by:
Hi
I am probably going to regret asking this because I'm sure you are going to
tell me my design is bad 8-) ah well we all have to learn....
anyway
I often use Nulls as a marker to see if...
|
by: Andy |
last post by:
First of all, can I reassure you that this posting is NOT spam and not
market research. Please feel free to email me at the address below to
check/validate this message prior to doing the survey if...
|
by: mike |
last post by:
I'm doing what I thought was a simple GROUP BY summary of fairly simple
data and the my numbers aren't working out
Some results are showing up <NULL> when I know the data is in the
database
...
|
by: Rhino |
last post by:
I am working with SQL Functions in DB2 for Windows/Linux/UNIX (V8.2.1) and
am having a problem setting input parameters for SQL Functions to null in
the Development Center.
My simple function,...
|
by: PST |
last post by:
Here's a problem I'm trying to deal with:
I'm working on a Frontpage 2000 website for a boat handicapping
system, built in Access 97.
What I'm trying to accomplish is:
The user enters a...
|
by: Andy |
last post by:
First of all, can I reassure you that this posting is NOT spam and not
market research. Please feel free to email me at the address below to
check/validate this message prior to doing the survey if...
|
by: natty2006 |
last post by:
Submission Deadline extended: 13 November 2006
*************************************************************
IADIS INTERNATIONAL CONFERENCE
APPLIED COMPUTING 2007
February 17-20, 2007 -...
|
by: Cliff72 |
last post by:
I need to fill in the nulls in the batch field the value from the
record immediately
preceding the null one ie replace the nulls with the preceding value
until I hit a record with a value in...
|
by: Aaron Watters |
last post by:
So, in between skiing runs I noticed
a Business Week cover story on
"cloud computing". The article had
lots of interesting information in it like
about how somebody's mom used to
be an airline...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |