Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 ColorCode

Author  Topic 

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2009-09-22 : 13:45:32
I'm trying understand the following part of a stored procedure and the term ColorCode in the procedure. I don't see ColorCode in the rest of the stored procedure, so I was wondering if ColorCode is a T-SQL command.

I'm using the stored procedure as part of a SQL report and I'm trying to understand what is populating ColorCode.

Any help would be greatly appreciated.

-----------------------------------------------------------

EXEC ('SELECT StartDateTime,
SystemName,
CASE WHEN CategoryName IS NULL OR CategoryName = ''''
THEN ''Not Defined''
ELSE CategoryName
END AS CategoryName,
CASE WHEN StartDateTime >= '''+@StartDateTime+''' AND EndDateTime <= '''+ @EndDateTime +'''
THEN DATEDIFF(ss,StartDateTime,EndDateTime)
WHEN StartDateTime >= '''+@StartDateTime+''' AND EndDateTime > '''+ @EndDateTime +'''
THEN DATEDIFF(ss,StartDateTime,'''+ @EndDateTime +''')
WHEN StartDateTime < '''+@StartDateTime+''' AND EndDateTime <= '''+ @EndDateTime +'''
THEN DATEDIFF(ss,'''+ @StartDateTime +''',EndDateTime)
WHEN StartDateTime < '''+@StartDateTime+''' AND EndDateTime > '''+ @EndDateTime +'''
THEN DATEDIFF(ss,'''+ @StartDateTime +''','''+ @EndDateTime +''')
END AS Duration ,
CASE WHEN ColorCode IS NULL
THEN ''Black''
ELSE ColorCode
END AS ColorCode

FROM [table]
WHERE ((StartDateTime >= '''+@StartDateTime+''' AND StartDateTime < '''+ @EndDateTime +''')
OR (EndDateTime > '''+@StartDateTime+''' AND EndDateTime <= '''+ @EndDateTime +''')
OR (StartDateTime < '''+@StartDateTime+''' AND EndDateTime > '''+ @EndDateTime +'''))
'+ @WhereClause +'
ORDER BY SystemName,StartDateTime')

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-22 : 14:21:44
It's a column in your table.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2009-09-22 : 14:55:56
I guess I'm confused because I don't know where my table is. Is this a temporary table?
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-09-22 : 15:01:48
Looks like it is a VIEW (based on the name). Look in the server's object explorer under "views"

Be One with the Optimizer
TG
Go to Top of Page

sfjtraps
Yak Posting Veteran

65 Posts

Posted - 2009-09-22 : 15:03:27
I understand now! Thank you!
Go to Top of Page
   

- Advertisement -