Reputation: 589
I'm trying to update a column named dattime
that is a date
column (not a datetime column like the name would lead you to believe) in my table named pr-pre-a
with the current date. I'm using SQL Server 2012 and when I use:
UPDATE pr-pre-a
SET [dattime] = getdate()
the getdate()
is not bolded meaning it is not a recognized command, and when I try to run it, it tells me there is a syntax error. however when I use:
UPDATE pr-pre-a
SET [dattime] = current_timestamp
it is bolded, but it still says there is a syntax error. What do I need to change to get this to work?
Upvotes: 1
Views: 1176
Reputation: 1085
Have you tried wrapping your table name in []?
I don't think SQL Server likes hyphens in table names without the square brackets or double apostrophes.
Upvotes: 1
Reputation: 93754
May be you need to escape -
in your table name using []
UPDATE [pr-pre-a]
SET [dattime] = getdate()
Upvotes: 2