查看存储过程文本中是否包含有该字符串--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
觉得写得不错,帮忙打赏下,谢谢!
用户名正确返回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
觉得写得不错,帮忙打赏下,谢谢!
相关文章推荐
- Sqlserver中查询存储过程是否包含某些文本
- sql 脚本 查看所有的存储过程及文本
- SQL查看数据库中包含临时表的所有存储过程
- SQL检查存储过程是否包含关键字
- 存储过程里动态生成包含SQL语句字符串
- sql server查询数据库中所有包含某文本的存储过程、视图和函数的SQL
- 查询数据库中所有包含某文本的存储过程、视图和函数的SQL
- 每日学习总结:DropDownList是否已选择验证、存储过程参数为sql字符串问题、将截断字符串或二进制数据。\r\n语句已终止
- Oracle中存储过程执行大的Sql语句时如何查看sql是否正确
- 每日学习总结:DropDownList是否已选择验证、存储过程参数为sql字符串问题、将截断字符串或二进制数据。\r\n语句已终止
- mysql查看存储过程和执行sql脚本文件到数据库中
- oracle sql语句怎么查询所有存储过程中是否包含某个注释?
- 验证选择每日学习总结:DropDownList是否已选择验证、存储过程参数为sql字符串问题、将截断字符串或二进制数据。\r\n语句已终止
- 快速查找所有存储过程中是否包含某个字符串
- sql在所有存储过程中查询包含某字符串的执行语句
- 查询数据库中所有包含某文本的存储过程、视图和函数的SQL
- SQL - 查找 过程、函数、触发器 是否包含 某个指定 字符串
- SQL 检索所有存储过程中是否包含某字符
- SQL脚本判断数据库、函数、 存储过程等是否存在的方法
- 将表数据生成SQL脚本的存储过程