Exists,Datediff,Newid,

---兩張關聯表,刪除主表中已經在副表中沒有的信息
delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )

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

---隨機取出10條數據
select top 10 * from tablename order by newid()

-- 類似有 month day year
select * from table1   where convert(varchar,date,120) like   '2006-04-01%' 
--datediff
select * from table1   where datediff(day,time,'2006-4-1')=0

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章