<%
function cip(sip)
tip=cstr(sip)
sip1=left(tip,cint(instr(tip,"")-1))
tip=mid(tip,cint(instr(tip,"")+1))
sip2=left(tip,cint(instr(tip,"")-1))
tip=mid(tip,cint(instr(tip,"")+1))
sip3=left(tip,cint(instr(tip,"")-1))
sip4=mid(tip,cint(instr(tip,"")+1))
cip=cint(sip1)256256256+cint(sip2)256256+cint(sip3)256+cint(sip4)
end function
ipconnpath = "ip/data/ipasp"
vip=Requestservervariables("REMOTE_ADDR")
%><%
set connip=servercreateobject("adodbconnection")
DBPath = ServerMapPath(ipconnpath)
connipOpen "driver={Microsoft Access Driver (mdb)};dbq=" & DBPath
ipnow=cip(vip)
Set rsip = ServerCreateObject("ADODBRecordset")
sql="select from ip where (startip<=" & ipnow & " and endip>=" & ipnow & ")"
rsipOpen sql,connip,1,1
vwhere=rsip("city")
rsipClose
set rsip=nothing
connipClose
set connip=nothing
if instr(vWhere, "广州市")>0 then '如果包含广州
ResponseRedirect "web/"
Responseend
end if
if instr(rsip("vWhere"), "河南")>0 then
ResponseRedirect "home/"
Responseend
end if
'其他的就不写了,照着我的写
%>
CREATE PROCEDURE [dbo][findStringFromSys]
-- Add the parameters for the stored procedure
@StringName varchar(255)
AS
BEGIN
--1定义需要查找的关键字。在搜索中,使用模糊搜索:LIKE '%@key_find%'
DECLARE @key_find NVARCHAR(MAX) = @StringName;--假设是找字符串"123"
--2用游标Cursor_Table,遍历所有表
DECLARE Cursor_Table CURSOR FOR
SELECT name from sysobjects WHERE xtype = 'u' AND name <> 'dtproperties';
OPEN Cursor_Table;
DECLARE @tableName NVARCHAR(MAX);
FETCH NEXT from Cursor_Table INTO @tableName;
WHILE @@fetch_status = 0
BEGIN
DECLARE @tempSQLText NVARCHAR(MAX) = '';
--3在表中,用游标columnCursor,遍历所有字段。注意,只遍历字符串类型的字段(列)
DECLARE columnCursor CURSOR FOR
SELECT Name FROM SysColumns WHERE ID = Object_Id( @tableName ) and
(
xtype = 35 or --text
xtype = 99 or --ntext
xtype = 167 or --varchar
xtype = 175 or --char
xtype = 231 or --nvarchar
xtype = 239 or --nchar
xtype = 241 --xml
)
OPEN columnCursor;
DECLARE @columnName NVARCHAR(MAX);
FETCH NEXT from columnCursor INTO @columnName;
WHILE @@fetch_status = 0
BEGIN
--4在表的字段中,对每一行进行模糊搜索,并输出找到的信息。
DECLARE @DynamicSQLText NVARCHAR(MAX) = 'IF ( EXISTS ( SELECT FROM [' + @tableName + '] WHERE [' + @columnName + '] LIKE ''%' + @key_find + '%'' ) ) BEGIN DECLARE @CurrentTableCount Bigint = ( SELECT COUNT() From [' + @tableName + '] ); PRINT ''Find : Table [' + @tableName + '], Column [' + @columnName + '], Row Count:'' + CAST( @CurrentTableCount AS NVARCHAR(MAX) ) + ''''; END';
EXEC( @DynamicSQLText );
FETCH NEXT from columnCursor INTO @columnName
END
exec(@tempSQLText);
CLOSE columnCursor;
DEALLOCATE columnCursor;
FETCH NEXT from Cursor_Table INTO @tableName;
END
CLOSE Cursor_Table;
DEALLOCATE Cursor_Table;
END
GO
以上就是关于查询数据库中字段包含某个值就跳转链接的问题全部的内容,包括:查询数据库中字段包含某个值就跳转链接的问题、sql2008中如果需要查询一个数据库中所有表的所有字段包含一个字符串应该怎么写、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)