Search for a string in that field of that table

zhaozj2021-02-16  53

- Search for a string in that field in that table

Declare @str varchar (100) set @ Str = 'White' - String to search

Declare @s varchar (8000) Declare TB CURSOR LOCAL FORSELECT S = 'IF EXISTS (SELECT 1 from [' B.Name '] Where [' a.name '] Like' '%' @ STR '%' ' ) Print '' The table and field: [' b.Name ']. [' A.name '] '' from syscolumns a join sysobjects b on a.id = B.Idwhere B.XTYPE = 'U 'and a.status> = 0 and A.XUSERTYPE IN (175, 239, 231, 167) Open tbfetch next from tb @Swhile @@ fetch_status = 0begin exec (@s) fetch next from tb @sendclose TBDEAllocate TB

/*--Test Results

The tables and fields: [Authors]. [Au_lname]

- * /

转载请注明原文地址:https://www.9cbs.com/read-23344.html

New Post(0)