1、說明:複製表(只複製結構,源表名:a 新表名:b) (Access可用)
法一:select * into b from a where 1<>1
法二:select top 0 * into b from a

2、說明:拷貝表(拷貝資料,源表名:a 目標表名:b) (Access可用)
insert into b(a, b, c) select d,e,f from b;

3、說明:跨資料庫之間表的拷貝(具體資料使用絕對路徑) (Access可用)
insert into b(a, b, c) select d,e,f from b in 『具體資料庫』 where 條件
例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where..


4、說明:子查詢(表名1:a 表名2:b)
select a,b,c from a where a IN (select d from b ) 或者: select a,b,c from a where a IN (1,2,3)

5、說明:移除重複記錄
Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)

6、說明:列出資料庫裡所有的表名
select name from sysobjects where type='U'

7、說明:列出表裡的所有的
select name from syscolumns where id=object_id('TableName')

8、說明:日程安排提前五分鍾提醒
SQL: select * from 日程安排 where datediff('minute',f開始時間,getdate())>5

9、壓縮資料庫
dbcc shrinkdatabase(dbname)
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 colud77 的頭像
    colud77

    I-Cloud程式攻略

    colud77 發表在 痞客邦 留言(0) 人氣()