不需要把值都赋为1,我只需要能sql语句把这几条查出来就行了
解决方案 »
- 一个SQL 判断 空值的问题。解决不了。急求大大解答
- sql server视频、Flash等文件
- 请给个Analysis Service Sp3 的下载地址
- 问个sql问题
- 求sql语句
- 题外话:webcast录制的视频2个小时才10M,我们录制2min就10M,这是什么技术,如何学会,哪里有这种技术,很高深么,为什么网上搜不到,郁闷
- 在线等待,请各位高手帮忙!!!!!!!!!!
- 我的SQL Server 不能创建数据库了,发生错误:1807 未能获得数据库 'model' 上的排它锁。请稍后重试操作。
- 为什么我昨天备份的数据库没有上周备份的数据库大
- 服务器的程序连SQL Server,大量操作时出现的问题
- 多表查询问题
- 将字符串分隔后,再形成列,谢谢。
with testcte as
(
select ID,ParentID,[Delete] from Test where ID=1
union all
select t.ID,t.ParentID,t.[Delete] from testcte as tc
join Test as t on t.ParentID=tc.ID
)update Test set [Delete]=1
where ID in(select ID from testcte)
--结果:
--ID ParentID Delete
--1 NULl 1
--2 1 1
--3 1 1
--4 2 1
create table Test
(
ID int null,
ParentID int null,
[Delete] int null
)
insert Test
select 1,null,0 union all
select 2,1,0 union all
select 3,1,0 union all
select 4,2,0
insert table
select 1 union all
查不出呢
create procedure toupdatetb(@id int)
as
begin
;with cte as
(
select ID,ParentID,[Delete] from Test where ID=@id
union all
select t.ID,t.ParentID,t.[Delete] from testcte as tc
join Test as t on t.ParentID=tc.ID
) update Test set [Delete]=1
where ID in(select ID from testcte)
end
goexec toupdatetb 1