Create Proc Proc_Find
--存储过程变量
@aName As Varchar(50)
As
--Set @aName='db_Pm'--要查找的字段名称
--游标变量
Declare @tableName As Varchar(50)
Declare cursorTablename Cursor
For(Select Name From DataBaseName..sysobjects Where xType='U')
Open cursorTablename
Fetch Next From cursorTablename
Into @tableName
While @@Fetch_Status=0
Begin
if exists(Select * From dbo.syscolumns Where Name= @aName And Id=Object_ID(@tableName))
Select @tableName
Else
Print '不存在'
Fetch Next From cursorTableName
Into @tableName
End
Close cursorTablename
Deallocate cursorTablename
--存储过程变量
@aName As Varchar(50)
As
--Set @aName='db_Pm'--要查找的字段名称
--游标变量
Declare @tableName As Varchar(50)
Declare cursorTablename Cursor
For(Select Name From DataBaseName..sysobjects Where xType='U')
Open cursorTablename
Fetch Next From cursorTablename
Into @tableName
While @@Fetch_Status=0
Begin
if exists(Select * From dbo.syscolumns Where Name= @aName And Id=Object_ID(@tableName))
Select @tableName
Else
Print '不存在'
Fetch Next From cursorTableName
Into @tableName
End
Close cursorTablename
Deallocate cursorTablename