日期:2014-05-18 浏览次数:20619 次
select * from 表A where name='哈'
------解决方案--------------------
declare @表A table (name varchar(2),xbegin int,xend int) insert into @表A select '哈',1830250,1830252 select name,xbegin=a.xbegin+number from @表A a left join (select number from master..spt_values where type='p') b on 1=1 where number <=xend-xbegin /* name xbegin ---- ----------- 哈 1830250 哈 1830251 哈 1830252 */
------解决方案--------------------
关联master..spt_values做数据。。。
------解决方案--------------------
select name,xbegin=a.xbegin+number from 表A a left join (select number from master..spt_values where type='p') b on 1=1 where number <=xend-xbegin
------解决方案--------------------
declare @表A table (name varchar(2),xbegin int,xend int) insert into @表A select '哈',1830250,1830252 select s.name,s.xbegin+number as xbegin from @表A s join master..spt_values on 1=1 where number<=xend-xbegin and type='p' (1 行受影响) name xbegin ---- ----------- 哈 1830250 哈 1830251 哈 1830252 (3 行受影响)