May 2, 2011 at 2:44 pm
I am truncated with some T-SQL statements.
The objective is to check for an empty string AND a Null value within a specific column of data in a row.
Take my example below:
CREATE PROCEDURE getIDs
@globalID varChar(50)
SELECT DISTINCT ISNULL(1stID, 2ndID) theID
FROM dbo.tableName
WHERE globalID = @globalID
-- What I have here is code that check to see if the 1stID is Null and if so, check the 2ndID and call it 'theID'...
-- What I need now is to also check to see if the 1stID or 2ndID returns empty or nothing in the column, in addition to NULL
I was pondering on using CASE statements then also IF/Else... but obviously became truncated.:w00t:
any ideas? examples?
May 2, 2011 at 3:35 pm
IF / ELSE is conditional processing of statements, so CASE would better match your requirements.
You will need to provide a more complete explanation of conditions and outcomes for a viable solution.
[theID] = CASE
WHEN 1stID IS NULL AND ... THEN ...
WHEN 1stID = '' THEN ...
WHEN 2ndID IS NULL THEN ...
WHEN 2ndID = '' THEN ...
ELSE ... END
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
May 2, 2011 at 8:38 pm
turns out CASE worked...I knew not its use and correct syntax.
thanks!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply