您的位置:首页 > 数据库

查看存储过程文本中是否包含有该字符串--SQL脚本

2013-08-26 16:04 447 查看
---------------------

用户名正确返回true,错误返回false

--exec [sp_login] '999'

ALTER PROCEDURE [dbo].[sp_login_lsx] 

@dm varchar(10),--登录员工工号
@pwd     varchar(100)

AS

--set nocount on

declare @val int

set @val=(case when @pwd<>'' AND @dm<>'' and  Exists(Select dm,pwd from ygdmbiao where dm=@dm and pwd=@pwd) then 1 else -1 end)

select @val

对应

[WebMethod]

        public string GetUserlfx(string dm, string pwd)

        {

            ShareSqlManager sql = new ShareSqlManager();

            DataSet dt = (DataSet)sql.ExecStoredProc("sp_login_lsx", "dm,pwd", new string[] { dm, pwd }, "DataSet");

            //return dt;

            if (dt != null && dt.Tables[0].Rows.Count > 0)

            {

                string result = dt.Tables[0].Rows[0][0] != null ? dt.Tables[0].Rows[0][0].ToString().Trim() : "";

                

                if (result=="1")

                {

                    return "true";

                }

            }

            return "false";

        }

-------------------

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- =============================================

-- Author: <Author,,NameXXX>

-- Create date: <Create Date,,2013年8月2日17:22:18>

-- Description: <Description,,查看存储过程文本中是否包含有该字符串--SQL脚本>

-- =============================================

CREATE PROCEDURE Sys_Search_StrToProce_Chk

@String varchar(2000)=''

AS

BEGIN
if exists(select * from sysobjects where xtype ='U' and name='tb_spNameOld'or name='tb_spNameNew')
begin
drop table tb_spNameOld
drop table tb_spNameNew
end
else
begin
create table tb_spNameOld (Id int identity , name varchar(2000)) --select * from tb_spNameOld
create table tb_spNameNew (Id int identity , name varchar(2000)) --select * from tb_spNameNew
insert into tb_spNameOld select name from sysobjects where xtype ='P'

declare @cur cursor
declare @Name varchar(2000)
set @cur = cursor for select name from tb_spNameOld
open @cur
fetch next from @cur into @Name
while(@@fetch_status=0)
begin
create table temp (text varchar(2000))
insert into temp exec sp_helptext @Name
if Exists(select * from temp  where  text like '%'+@String+'%')
begin
insert into tb_spNameNew select @Name
end
drop table temp
fetch next from @cur into @Name
End
close @cur
--关闭游标 
deallocate @cur
select * from tb_spNameNew
end

END
GO

觉得写得不错,帮忙打赏下,谢谢!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐