Home > Mobile >  how to get current date only in database table
how to get current date only in database table

Time:09-09

I have two tables in my database, where my second table has one extra column "date" and I want to copy my first table data to second with current date

so I tried this SQL SERVER query INSERT INTO table2 SELECT * FROM table1, GETDATE();

and I get an error invalid object name 'GETDATE'.

CodePudding user response:

Specify any values you want to include in the SELECT clause:

INSERT INTO TABLE2 (Field1,Field2,Date)
SELECT Field1,Field2,GETDATE()
FROM TABLE1;

The FROM clause is only used to specify the query's data sources: tables, subqueries, table-valued functions.

  • Related