|
I am trying to alter a table by adding a new column. New column name = today's date. I don't know how to code the apostrophe. Trying ALTER TABLE tblname ADD today's date DATETIME
(comments are locked)
|
|
OK @Usman has shown you how to do it and @Magnus has explained the dangers in doing so, but I have to ask why you would want to store a value of today's date in a column? That does smell like a bad design. What happens when I read the data entered yesterday, tomorrow? Even if the table only ever contains "today's" data, name the column with something that reflects what the date means (e.g. EnteredDate, InsertedDate, LogDate, etc) - then you can see easily if the data has been refreshed. If the data never can go stale, and is always "today's" then no need to store a date at all Absolutely great advice.
Apr 18 '12 at 08:55 AM
Grant Fritchey ♦♦
(comments are locked)
|
|
There are couple of ways you can do this, but I prefer not to use spaces,single quotes etc. in the object names Anyways, one way to do it is to put square brackets around the column name i.e. Another way is to have I totally agree about not using single quotes or apostrophes in object names. The above is just one of the many reasons to avoid it :)
Apr 18 '12 at 05:46 AM
Magnus Ahlkvist
(comments are locked)
|


Two good answers, please be sure to mark which one you find most helpful.