Say I already have a table which has the following fields...
ColPK, ColClosed, ColExpired --both ColClosed and ColExpired are bit dataTypes (i.e. True or False)
354 1 0
355 0 0
356 0 1
I now have a second table that I want to populate from MyTable1, but my second col (MyTable2.ColStatus) is a result of ColClosed and ColExpired...
How do I write a query to achieve the above results?
SELECT ColPK As 'PK', (an If statement? or can I call a Procedure?) As 'Status'
A Procedure could look like:
CREATE Procedure dbo.GetSTATUS
@STATUS nvarchar(255) Output
If @Closed = 1
Set @STATUS = 'CLOSED'
If @Expired = 1
Set @STATUS = 'EXPIRED'
If @Closed = 0 And @Expired = 0
Set @STATUS = 'OPEN'