Today, I encountered a strange problem in configuration: 192.168.x.x, the operating system win2008x64sp1, and the database sqlserver2008 phenomenon: SQL Server query, the local machine is normal, other machines in the same network segment, the query speed is very slow (login is fast, 250 records of small table query time close to 30 seconds) solution: After query, it is the management software in the Broadc
1. usage of the Case Function(1) Use the following commands: switch-case and if-else if.(2) Syntax:Case [field]When expression then display dataWhen expression then display dataElse display dataEnd(3) percent conversion of Quality Education1) We want to convert the displayed data to ABCDE. The rule is to show A at or above 90 points, B at or above 80 points, and so on.
2) The executed
The server case may be one of the most misused keywords in SQL. Although you may have used this keyword before to create a field, it has more usage. For example, you can use case in the WHERE clause. First let's look at the syntax of CASE. In general SELECT, its syntax is as
The Code is as follows:
The structure of the landundertake table is as follows:
The structure of the table appraiser is as follows:
Access code:
Copy codeThe Code is AS follows: TRANSFORM First (Landundertake. valuerId) AS First of valuerId
SELECT Appraiser. quarterId, Landundertake. landCode
FROM Landundertake inner join Appraiser ON (Landundertake. valuerId = Appraiser. valuerID) AND (Landundertake. quarterId = Appraiser. quarterId)
Group by Appraiser. quarterId, Landundertake. landCode
PIVO
Case
It may be one of the keywords most misused in SQL. Although you may have used this keyword before to create a field, it also has more features. For example, you can
Where
Clause
Case
.First, let's take a look.
Case
. In normal
Select
The syntax is as follows:
Select
Mycolumnspec
>
toilet, be sure to obtain a complete lock, close the door to let others come in, otherwise if the other people came in, although he did not occupy the seat, but he took the toilet paper. You occupy the seat but no toilet paper, he took the toilet paper but no seat, the two sides do not give, who can not complete the toilet affairs, stalemate, and lead to deadlock. At this point you need to come to the toilet management, or force you to let go of the seat, do not manage you wipe your butt, or gr
Server
-----------------------------------------------------------------------------------------------
Author: Ongyan
Welcome to reprint, please retain this statement information.
Welcome to contact me, enhydra_boy@tom.com.
----------------------------------------------------------------------------------------------
Recently, in the CSDN forum, before and after answering the question of two friends, feel the need to sum up.
The problem is this.
EXCEPT/INTERSECT, CASE/ISNULL/COALESCE in SQL SERVEREXCEPT and INTERSECT
General explanation: Compare the results of two queries and return non-repeated values.
EXCEPTFrom the left query, all non-repeated values not found in the right query are returned.
INTERSECTReturns all non-repeated values in both the left and right queries.
The following are the basic rules that combine the result sets of two queries
The table game_info is known as follows
Date_info
Result_info
2018-2-4
Win
2018-2-4
Lose
2018-2-4
Win
2018-2-4
Lose
2018-2-5
Lose
2018-2-5
Lose
2018-2-5
Lose
Q. How do I find the following results?
Date_info
Win
Lose
2018-2-4
2
2
2018-2-5
0
3
Because the local database is not set to partition size during installation, but the server is a partition, I re-wrote some code, in order not to let this happen, I decided to change the local database to support the size of the region.
The Code is as follows:
Alter database databasenameCollate chinese_taiwan_stroke_cs_as
CiCase Insensitive,CSSpecifies the case sensitivity.
If it is a simplified versi
1. IF ELSEcannot be used in select, only blocks, such as:IF ...BEGIN...ENDelse (note that there is no else if, to be implemented can only be judged in the following block)BEGIN...ENDReference: Https://msdn.microsoft.com/en-us/library/ms182587.aspx2. Case and then ELSE ENDCan be used in select, but include end endCase ...When ... Then ...ELSE ... (can be omitted)ENDReference: Https://msdn.microsoft.com/en-us/library/ms181765.aspxSQL
I used a stupid method, but I don't know if there are other good methods:
Compare the field to be modified with the field in the stored procedure and change it to the same size, the same type, and the order to be completely the same. This still does not work, and re-compilation is not successful, when SQL Server is stopped and restarted, some parameters in the stored procedure can be used as annotations, r
implement a query with a single statement. But that increases the consumption (two select parts), and the SQL statement is longer.Here is an example of using the case function to accomplish this function SELECT country,
sum (case if sex = ' 1 ' then
population ELSE 0 END), --Male population
SUM (case if sex = ' 2 ' T
When a database server (Microsoft SQL Server (SP2) (KB3171021)-12.0.5000.0 (X64) discovered that a job called Database Mail sent a message, sometimes the same message was sent two times, After detailed inspection, to exclude the business logic in the job, there is a problem in the case of duplicate sending mail, check
Tags: reference name col except contact Att sink ber walSQL Server Table Management _ Detailed information on the operation of data deletion and modification (case code)-DML 1. SQL INSERT INTO statement (insert in table) The INSERT INTO statement is used to insert a new record into the table. SQL INSERT into Syntax The
Case when usageSELECT L.lettertype, u.realname from T_lettersrecord as L, t_user as U WHERE (case when l.lettertype = ' Cadre Letter of introduction ' and U.userid = ' 1 ' THEN1 whenl.lettertype = ' Cadre Letter of introduction ' and u.userid Operation Result:3. Use of GROUP by caseSELECT Case wh
!))。 Restart the service, run a day, and then look at the Event Viewer, no longer found similar records, CPU utilization decreased to about 5, the system response significantly faster. The problem has been satisfactorily resolved.To prevent hackers from traversing the system login account. Administrator was renamed, but after renaming, SQL Server could not start. Found
Copy Code code as follows:
--Simple Case function
Case Sex
When ' 1 ' THEN ' male '
When ' 2 ' THEN ' woman '
Else ' other ' end
--case search function
case when sex = ' 1 ' THEN ' man '
When sex = ' 2 ' THEN ' female '
Else ' other ' end
In both of these ways, you can achieve the same
--Simple Case functionCase SexWhen ' 1 ' THEN ' male 'When ' 2 ' THEN ' woman 'Else ' other ' end--case search functioncase when sex = ' 1 ' THEN ' man 'When sex = ' 2 ' THEN ' female 'Else ' other ' end
In both of these ways, you can achieve the same functionality. The simple case function is relatively concise, but there are some limitations to the function, s
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.