SQL checks whether Stored Procedures contain keywords. SQL stored procedures

Source: Internet
Author: User

SQL checks whether Stored Procedures contain keywords. SQL stored procedures

Select. name from sys. ALL_OBJECTS A, SYS. SQL _MODULES B WHERE. IS_MS_SHIPPED = 0 and. OBJECT_ID = B. OBJECT_ID and. [TYPE] IN ('P', 'V', 'af') AND [DEFINITION] LIKE '%' -- the keyword order by. [NAME] ASC


SQL query problem (query for any keyword in all columns)

According to your requirements, an SQL statement cannot be completed.
You can write dynamic SQL statements or stored procedures only using the database system tables (storing each attribute column of each table.

SQL queries all records whose fields contain a certain keyword

In general, as long as the keyword field and keyword are compared by like, all fields are not compared.

As for "Will it cause the database to refuse execution? There are also efficiency issues. "We suggest you write a stored procedure and execute the storage.

For example:

Go
Create procedure GetKeyWordRecord @ keyWord varchar (20)
As
Set @ keyWord = '%' + @ keyWord + '%'
Select * from your table
Where
Your field 1 like @ keyWord or
Your field 2 like @ keyWord or
Your field 3 like @ keyWord or
Your field 4 like @ keyWord or
Your field 5 like @ keyWord --- more fields are omitted
Go

Exec GetKeyWordRecord 'key'

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.