Link to home
Start Free TrialLog in
Avatar of TechMonster
TechMonster

asked on

Sql 2005- Query column / insert date

Have an existing table with a date column. There is no dates/data in the column.

Need to query column and insert current date into my query.  

I was trying

select getdate() as [Date]

Doesn't work with Sql 2005.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of MikeWalsh
MikeWalsh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Anthony Perkins
>>Doesn't work with Sql 2005. <<
Can you elaborate what that means, does it:
A. Give you an error message, if so what is it.
B. Give you the wrong results, as in the time in Greenland.
C. Smoke starts emanating from your monitor evey time you use it.
I am offended by your comments anthony..

Why does everyone have to pick on Greenland? Who is to say the time in Greenland is the wrong result???

<g>
Only if you live in NH :)

But seriously, I apologize to the questioner for my sarcasm, but the totally useless phrase "doesn't work" is a long time pet peeve of mine and I have seen three separate instances of it today alone.  What boggles my mind is that as software engineers we should be particularly sensitive to this and yet we are all guilty of using it.
Yes, I had seen it (and where it originated).  Good idea, but what are the chances of it coming to fruition?
probably as likely as us getting T-Shirts ;-)
Avatar of TechMonster
TechMonster

ASKER

MikeWalsh,

Thank you for your response.  I have one question though.  Will not the code you listed insert the date into my table that I am quering?

INSERT TableName
(DateColumn)
SELECT GETDATE()

I only have read access to my table and was looking for a way to populate the current date into the blank column
only in my query.  I am actually making a new table from the old table I am quering from.



sorry

so you are not doing an insert then do this:

SELECT columnName,columnName, getdate() as [Current Date], ColumnName
FROM TableName
Well I am biased here, but I think I gave him the answer and explained the premise. He asked no followup so I believe my answer helped him. So I say force accept MikeWalsh
>>but I think I gave him the answer and explained the premise<<
I would concur.  Hopefully a Moderator will be kind enough to delete all my off-topic ranting and raving.