In SQL, sometimes we need to select some data from one table and insert data into another table, this can be done as follows with a simple sql query:
Insert into Table1 (c1, c2, c3, c4, c5)
(Select c1, c2, c3, c4, c5 from Table2)
But make sure that both the tables have same fields, data type..
Sometimes we need to have only date from datetime field in sql.
There are number of ways to accomplish that:
Suppose we take current date
now to take only date from current date excluding time, we do as follows in various ways:
select DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
select cast(cast(getdate() as int) as datetime)
select cast(convert(varchar,getdate(),110) as datetime)