1、 查询表中所有数据;
SELECT *
FROM tabla_source
2、 查询表中指定字段的数据;
SELECT 字段名
FROM table_source
SELECT snarne,sex,telephone
FROM strLinfo
3、 查询结果中去除重复信息;
SELECT DISTINCT depart
FROM stu_info
4、 根据现有列值计算新列值;
SELECT sname,DATEDIFF(year,birth,GETDATE())
FROM stu_info
5、 命名新列;
SELECT sname,DATEDIFF(year,birth,GETDATE() AS 年龄
FROM stu_info
6、 将查询结果保存为新表;
SELECT *(或字段列表)
INTO 新表名
FROM table_source
SELECT sname,DATEDIFF (year,birth, GETDATE()) AS 年龄
INTO age
FROM stu_info
7、 连接字段;
SELECT sname+depart
FROM stu_info
SELECT sname+depart AS 姓名及来源地
FROM Stu_info
SELECT RTRIM(sname)+'('+RTRIM(depart)+')' As姓名及来源地
FROM stu_info
8、 ;