2017年9月14日 星期四

SQL Server Data Format

1.   Get Date in a format such as: 2017/09/11

CONVERT(char(10),DATEADD(day,-(1),GETDATE()) ,111) AS Date

2017年9月13日 星期三

Select Into v.s. Insert into From

1. Select Into

Create a new table in the destination database
select * into sif.dbo.callDetail from I3_IC.dbo.calldetail_viw;

2.  Insert into From

Insert into existing table, column needs to assigned explicitly. * may not work in some databases.

INSERT INTO table2 (column1column2column3, ...)
SELECT column1column2column3, ...
FROM table1
WHERE condition;