Retrieving cloumn from SQL server stored proc

  • Thread starter Thread starter iHavAQuestion
  • Start date Start date
I

iHavAQuestion

I have to retrieve the cloums from the table, but there are few columns in a
table of datatype date and int and the default values are 9999-12-31
23:59:59.997 and -2147483648.

My questions is when I retreive them I sould get value as NOTHING, i mean
blank.

Can any one give me the solution.
 
You can do something like:

SELECT
CASE
WHEN DateColumn>'9999-12-31' THEN NULL
ELSE DateColumn
END AS DateColumn,
CASE
WHEN IntColumn<=-2147483684 THEN NULL
ELSE IntColumn
END AS IntColumn,
...
FROM theTable
WHER...

This just a simple and quick way. Of course you can have finer control with
more "WHEN...' in the CASE...END clause in conjunction with WHERE... to get
what you want to retrieve from the table
 
Back
Top