declare @roop int
Set @roop=1
while @roop<4
begin
if Not Exists(Select * from 表 where 用户=@roop and 服务=1)
Insert Into 表 values(@roop,1)
if Not Exists(Select * from 表 where 用户=@roop and 服务=2)
Insert Into 表 values(@roop,2)
if Not Exists(Select * from 表 where 用户=@roop and 服务=3)
Insert Into 表 values(@roop,3)
if Not Exists(Select * from 表 where 用户=@roop and 服务=4)
Insert Into 表 values(@roop,4)
Set @roop=@roop+1end
Set @roop=1
while @roop<4
begin
if Not Exists(Select * from 表 where 用户=@roop and 服务=1)
Insert Into 表 values(@roop,1)
if Not Exists(Select * from 表 where 用户=@roop and 服务=2)
Insert Into 表 values(@roop,2)
if Not Exists(Select * from 表 where 用户=@roop and 服务=3)
Insert Into 表 values(@roop,3)
if Not Exists(Select * from 表 where 用户=@roop and 服务=4)
Insert Into 表 values(@roop,4)
Set @roop=@roop+1end
解决方案 »
- 数据库中表table ,tid是外键,其中有'01’,'02’...等值。删除掉非01,02关联的所有值。
- 如何让内存中的DataTable与数据库的表连接?
- DBA怎么连接sqlserver数据库
- 在sql2005中还原bak文件出现错误高手来看
- 索引问题探讨研究
- sql server 2005 中有个表无法打开
- ACCESS允许位操作吗?
- 将查询结果转存到临时表中的问题
- 关于学校的数据库系统,大家都来讨论一下好吗^_^
- 异常详细信息: System.Data.SqlClient.SqlException: '=' 附近有语法错误。
- 急!!!!关于sql语句的写法
- 有人在2003 server上升级过MDAC2.7 sp1吗?
select a.user_id,b.serv_id from usertable a,servtable b order by a.user_id,b.serv_id