INSERT INTO TABLE (COL1) VALUES SYSDATE;
How is this accomplished in sql? I am using a datetime data type, I
hope that is correct . . .
Thank you for your help.
Ryan
p.s. I tried getdate(), getdate, sysdate, and current_timestamp. All
to no avail :(
I'm new to SQL Server myself, but for your question, this works for me:
INSERT INTO MyTable (colA)
VALUES (GetDate())
HTH
--
Message posted via http://www.sqlmonster.com
--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.developersdex.com/gurus/default.asp?p=4223
---------------------------------------
INSERT INTO TABLE (COL1) SELECT getdate()
or
SELECT getdate() INTO TABLE
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.developersdex.com/gurus/default.asp?p=4223
>Hi all, I have a question about inserting records into sql server. I
>am brand new to sql server, always using oracle previously. Before
>today, I had always written statement such as this:
>
>INSERT INTO TABLE (COL1) VALUES SYSDATE;
Hi Ryan,
Is this a straight copy-and-paste from working Oracle code? The SQL
standard calls for parentheses in the values clause.
(snip)
>p.s. I tried getdate(), getdate, sysdate, and current_timestamp. All
>to no avail :(
Both CURRENT_TIMESTAMP (the ANSI-standard keyword) and getdate() (the
T-SQL proprietary equivalent) should work - but only if you include the
parentheses, and escape the tablename ("table" is a reserved word):
INSERT INTO "TABLE" (COL1) VALUES (CURRENT_TIMESTAMP);
If this doesn't work, then post back with the DDL (the CREATE TABLE
statement used for your table "TABLE"), the complete code, and the exact
error message you get.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Thanks again and have a great weekend!
Ryan