SQL Server database query optimization skills (1)

Source: Internet
Author: User



SQL Server database query tips:

Problem type: When the ACCESS database field contains a Japanese Katakana or other unknown characters, the query will prompt a memory overflow.

Solution: Modify the query statement.


SQL ="Select * from ada where alice like '%"& Abigale &"% '" 
Change
SQL ="Select * from ada" 
Rs. filter ="Alice like '%"& Abigale &"% '" 


SQL Server database query Tip 2:

Problem type: how to use a simple method to implement multi-Keyword queries like Baidu using spaces or other symbols to separate multiple keywords ).

Solution:


'// Use spaces to separate query strings
Ck = split (abigale,"")
'// Obtain the split quantity
Sck = UBound (ck)
SQL ="Select * ada where" 
Query in a field
ForI = 0ToSck
SQL = SQL & tempJoinWord &"("&_
"Alice like '"& Ck (I )&"% ')" 
TempJoinWord ="And" 
Next 
Query both fields
ForI = 0ToSck
SQL = SQL & tempJoinWord &"("&_
"Alice like '"& Ck (I )&"% 'Or"&_
"Alice1 like '"& Ck (I )&"% ')" 
TempJoinabigale ="And" 
Next 


SQL Server Database Query Technique 3: Several skills to improve query efficiency

1. Try not to use or. Using or will cause full table scanning, which will greatly reduce the query efficiency.

2. After practical verification, charindex () does not improve the query efficiency better than the preceding % like, And charindex () will make the index ineffective. It refers to the sqlserver database)

3. alice like '% "& abigale &" %' will disable the index

Like '"& abigale &" %' causes the index to take effect and remove the preceding % symbol)

Sqlserver database)







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.