科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道[Sql server]教程SQL存储过程和算法(6)

[Sql server]教程SQL存储过程和算法(6)

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

if exists (select * from dbo.sysobjects where id = object_id(N\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'[dbo].[t]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\') and OBJECTPROPERTY(id, N\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'IsUserTable\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\') = 1)

作者:iTbulo.COM 来源:iTbulo.COM 2007年9月15日

关键字: 存储过程 SQL Server SQL Server 各版本 数据库

  • 评论
  • 分享微博
  • 分享邮件

INSERT INTO #tmp1 (tmp1_name)

SELECT DISTINCT b.[name] FROM t a,t b WHERE a.[name] = @CurrenName AND b.lid = a.lid AND b.[name] <> @CurrenName

INSERT INTO #tmp (tmp_name)

select d.[tmp1_name] from t a,t b,t c, #tmp1 d where

a.lid=b.lid and a.[type]=b.[type] and a.id and a.[name] = d.[tmp1_name] and b.[name] = @name2

and c.id>=a.id and c.id<=b.id

IF @@rowcount>0 BEGIN

select distinct c.* from t a,t b,t c,#tmp d where

a.lid=b.lid and a.[type]=b.[type] and a.id and a.[name] = @name1 and b.[name] = d.tmp_name

and c.id>=a.id and c.id<=b.id order by c.id

select distinct c.* from t a,t b,t c,#tmp d where

a.lid=b.lid and a.[type]=b.[type] and a.id and a.[name] = d.tmp_name and b.[name] = @name2

and c.id>=a.id and c.id<=b.id order by c.id

END

--SELECT * FROM #tmp

end

drop table #result

drop table #tmp1

drop table #tmp

GO

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS ON

GO

exec search '文一路口','总管塘'

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章