34,838
社区成员




create function getTa(@b varchar(200))
returns @a table(id int identity(1,1),a char(1))
as
begin
declare @i int
set @i=1
while @i<=len(@b)
begin
insert @a select substring(@b,@i,1)
set @i=@i+1
end
return
end
declare @a table(a varchar(20),b varchar(100))
insert @a select '计算机' ,'11111111111000000000'
union all select '软件工程','00111111100000000000'
union all select '高数' ,'00101110110000000000'
declare @c varchar(100),@d varchar(100)
select @c=b from @a where a='计算机'
select @d=b from @a where a='软件工程'
select a.id from
dbo.getTa(@c) a
inner join
dbo.getta(@d) b
on a.id=b.id and a.a=b.a where a.a=1
--result
/*id
-----------
3
4
5
6
7
8
9
(所影响的行数为 7 行)
*/
...
declare @1 int,@2 int
select @1=cast(substring(@s1,@begin,1) as int),@2=cast(substring(@s2,@begin,1) as int)
if (@1&@2=1)
select @result='有', @begin=@end
else if(@1&@2!=1)
select @begin=@begin+1
...
...
declare @1 int,@2 int
select @1=cast(substring(@s1,@begin,1) as int),@2=cast(substring(@s2,@begin,1) as int)
if (@1&@2=1) begin
set @result='有'
set @begin=@end
end
else if(@1&@2!=1)
select @begin=@begin+1
...