Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Dummy" column in SELECT

Status
Not open for further replies.

djj55

Programmer
Joined
Feb 6, 2006
Messages
1,761
Location
US
Hello,
I would like to add a column to a select statement that is smalldatetime but I want it initialized it to null.
Code:
SELECT DISTINCT myCol1, myCol2, NULL AS NEW_SDT 
INTO #Temp 
FROM mytable
as NEW_SDT would not be a smalldatetime this does not work.

I can create the table before the select but would rather know if there is a way to create the column on the fly.

Thank you,

djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 
Did you try converting the null to DateTime?

Select Convert(DateTime, NULL) As NEW_SDT

I don't know if this will work, but it's worth a try.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thank you, works great.


djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top