易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL语句PART7

Merge statement
function benefits: 1) provides the ability to conditionally update, insert or delete data into a database table. 2) performs an update if the row exists, and an insert if it is a new row. --> 1) avoids seperate updates, 2) increase performance and ease of use. 3) is useful in data warehousing applications.
syntax:
MERGE INTO table_name table_alias
USING (table|view|sub_query) alias
ON (join condition)
WHEN MATCHED THEN
UPDATE SET
col1 = col1_val,
col2 = col2_val
WHEN NOT MATCHED THEN
INSERT (column_list)
VALUES (column_values);
e.g.: table: temp_t1:
results:
1    1    收文            SHOUWEN
2    1    发文            FAWEN
3    1    交办            JIAOBAN
4    2    值班报告     REPORT
5    3    督察督办     SUPERVISAL
6    2    值班快报     DAILYREPORT
7    2    我的事情     NOTIFY
8    4    提案            RESOLUTION
9    4    建议            SUGGESTION
e.g.: table: temp_t2:
results:
1    1    收文            SHOUWEN
2    1    发文            FAWEN
3    1    交办            JIAOBAN
4    2    值班报告     REPORT
5    3    督察督办    


相关文档:

SQL Server 2005 日志删除和日志文件限制(转)


SQL Server 2005 日志删除和日志文件限制(转)
2009年08月04日 星期二 下午 04:40
清除日志:
DECLARE @LogicalFileName sysname,
         @MaxMinutes INT,
         @NewSize INT
USE      szwzcheck ......

sql函数常用函数

1.     select replace(CA_SPELL,' ','') from hy_city_area  去除列中的所有空格
2.     LTRIM() 函数把字符串头部的空格去掉
3.     RTRIM() 函数把字符串尾部的空格去掉
4.     select LOWER(replace(CA_SPELL,' ','')) f ......

sql游标

因为要根据很复杂的规则处理用户数据,所以这里用到数据库的游标。平时不怎么用这个,写在这里纯粹为自己备个忘。
--将学籍号重复的放入临时表 tmp_zdsoft_unitive_code(除高中学段外)
drop table tmp_zdsoft_unitive_code;
select s.id ,sch.school_code,sch.school_name,s.student_name,s.unitive_code,s.identity_car ......

SQL语句PART2

Subquery: (single-row subqueries and multi-rows subqueries).
select select_list
from table
where expr operator (select select_list from table);
single-row subqueries operator: =, >, >=, <, <=, <>
e.g.:
1. select department_id, min(salary) from employees group by department_id ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号