First step: Create a stored procedure that queries the value of a value in which field in a table exists
Create procspfind_column_in_db (@type int,--Type: 1 for text type, 2 for numeric type @str nvarchar( -)--name to search for) as --create temporary tables to hold results Create Table#tbl (PKint Identity Primary Key, tbl sysname,col sysname)Declare @tbl nvarchar( -),@colsysname@sql nvarchar( +) if @type=1 begin DeclareCurtablecursorFast_forward for Select '['+Schema_name (schema_id)+']. ['+O.name+']'TableName,'['+C.name+']'ColumnName fromSys.columns CInner JoinSys.objects o onC.object_id=O.object_id whereO.type_desc='user_table' anduser_type_idinch(167,175,231,239, *, About) End Else begin DeclareCurtablecursorFast_forward for Select '['+Schema_name (schema_id)+']. ['+O.name+']'TableName,'['+C.name+']'ColumnName fromSys.columns CInner JoinSys.objects o onC.object_id=O.object_id whereO.type_desc='user_table' anduser_type_idinch( About, -, the, -, -, +,106,108,122) End OpencurtableFetch Next fromCurtable into @tbl,@col while @ @FETCH_STATUS=0 begin Set @sql='if exists (SELECT * from'+@tbl+'where' if @type=1 begin Set @sql += @col + ' like"'%'+@str +'%"')' End Else begin Set @sql +=@col + 'In ('+@str+'))' End Set @sql += 'INSERT #TBL (tbl,col) VALUES (" "+@tbl+" "," "+@col+" ")' --Print @sql exec(@sql) Fetch Next fromCurtable into @tbl,@col End ClosecurtabledeallocatecurtableSelect * from#tbl
Step two: Find this newly generated stored procedure from the database.
Step Three:
After clicking OK
Fourth step: Right-click spfind_column_in_db_limy-> Execute Stored Procedure
Fill in the parameters as needed.
SQL statements that might be used with it:
View views, stored procedures, functions related to a table
Select a.* from sysobjects A, syscomments b where a.id = b.ID and b.text like '% table name% '
MSSQL queries a value for the value of which field in a table is present.