Sql查询问题
--检查临时表
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempwk'))
Drop table #tempwk
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempPer'))
Drop table #tempPer
if exists(select * from tempdb..sysobjects where id=object_id('tempdb..#tempList'))
Drop table #tempList
-- 周一开始
select fDate into #tempwk from (
select DATEADD(wk,DATEDIFF(wk,0,getdate()),0) fDate
union
select DATEADD(wk,DATEDIFF(wk,0,getdate()),1)
union
select DATEADD(wk,DATEDIFF(wk,0,getdate()),2)
union
select DATEADD(wk,DATEDIFF(wk,0,getdate()),3)
union
select DATEADD(wk,DATEDIFF(wk,0,getdate()),4)
union
select DATEADD(wk,DATEDIFF(wk,0,getdate()),5)
union
select DATEADD(wk,DATEDIFF(wk,0,getdate()),6)
) T
--人员
select fName into #tempPer from (
select '张三' fName
union
select '李四'
) T
select fDate, fName into #tempList from #tempwk,#tempPer
--人员
insert into #tempPer(fName) values('王五')
--周人员列表
insert into #tempList(fName,fDate) values('王五','2013-04-22')
insert into #tempList
select fDate, fName from #tempwk,#tempPer
where ???(这里如何不重复插入数据 1.张三、李四不重复插入 2.王五 22号不重复插入)
select * from #tempList
...全文
相关推荐
SQL高级查询语句关键时候解决问题的SQL语句
SQL高级查询语句 有用的 关键时候解决问题的SQL语句 SQL高级查询语句 有用的 关键时候解决问题的SQL语句
sql 分组查询问题
sql 分组查询问题,需要的朋友可以参考下。
SQL2005常见查询问题
这里包含SQL2005查询编程过程中遇到的基本问题,一级样子例程,是非常不错的资源。
SQL语言中具有全称量词的查询问题.pdf
SQL语言中具有全称量词的查询问题.pdf
使用SQL查询插入数据的问题
插入失踪的信息(mfname,mlname,id)值('john','wilson',(从用户\u540d='abc@abc.com'的帐户中选择ID))


