Copy codeThe Code is as follows:-determines whether some fields are empty.
-- Case
Select case when 'field name' is null then' \ n' else convert (varchar (20), 'field name') end as 'newname'
Select case when null is null then' \ n' else convert (varchar (20), null) end as 'newname'
-- SQL Server 2005: coalesceSelect coalesce ('string type field', '\ n') as 'newname'Select
" column?We must use the is not NULL operator:SELECT lastname,firstname,address from Personswhere Address was not NULLResult set:
LastName
FirstName
Address
Bush
George
Fifth Avenue
In the next section, we learn about the ISNULL (), NVL (), Ifnull (), and coalesce () functions.SQL NULL functions sql ISNULL (), NVL (), Ifnull (), and
35. use SQL query analyzer and SQL profilerUse SQL query AnalyzerUse SQL profilerOptimize T-SQL statementSummaryIn this chapter, we will continue with the description of the pre-stored procedures in Chapter 21st. This chapter describes how to use
when sorting:
123
selectname, coalesce(points, 0)from usersorder by 2 descnulls last;
Of course, NULL can also be used to prevent errors, such as handling mathematical errors with a divisor of 0.be removed by 0A divisor of 0 is a very egg-painfull error. Yesterday also run a good SQL, suddenly by 0 except a sudden error. A common workaround is to use a case statement to dete
13. T-SQL and SQL query AnalyzerWhat is SQL?What is T-SQL?Introduce new features of T-SQLHow to Use T-SQLSummaryIn this chapter, we will introduce some basic concepts about the Structured Query Language What is SQL? SQL is a datab
SELECT field1/field2 from TB;When the value of Field1 > Field2, the result of division is This time, in the DB2 environment, the value of select is 0.How to resolve:First convert the field1 into a double type, so the calculation will draw a decimal point, will show 0.xxxxSELECT CAST (field1 as FLOAT)/field2 from TB;ps. Internet search information, write a double, but in SQL Server2008 has been wrong, changed to float is no problem.The decimal point sh
Tags: and fast speaking tuning market buffer way a completely"High-performance SQL Tuning essentials and Case Resolution" a book has been launched, many enthusiastic readers on the contents of the book and some of the specific questions raised questions, because of the numerous readers plus my daily work busy, here on the SQL tuning learning to discuss and a unified answer to the hot issues.First, let's tal
Sqlserver Management
Common field types: Bit (optional values: 0, 1), datetime, Int, varchar, and nvarchar (may contain nvarchar for Chinese)
Differences between varchar, nvarchar, and char (N): Fill in spaces for less than N parts of char (n. VaR: Variable, variable.
SQL statements
Use strings in SQL statementsSingle quotes.
SQL
This article is a record of the programmer's SQL code, and this time it will cover other functions commonly used by SQL Server. (Other database is not listed here, want to see more attention to the "Programmer's SQL Code").
Other functions include: type conversion functions, null value processing functions, Process Control functions,
Sqlserver supports locating the current page and customizing sorted paging SQL statements (rejecting dynamic SQL statements)
Sqlserver supports locating the current page and customizing sorted paging SQL statements (rejecting dynamic SQL statements)
1. Scenario: query by student ID and return all students in the stude
Select COUNT (VIRTUALACC) into V_count from t_atmmonitor WHERE VIRTUALACC = v_number;For the stored procedure, the value of the count (VIRTUALACC) statistic is assigned to the variable v_count, and the V_count variable is called in subsequent stored procedures.In the SQL statementSelect into from and insert into select differGrammar:Insert into table2 (field1,field2, ... ) Select Value1,value2, ... From table1Requirements table2 must existThe differen
---- Set a non-primary key to clustered index [Step 4] to: http://king123654789.iteye.com/blog/1169191
1. View All indexes. Clustered indexes are created on the primary key by default.Sp_helpindex person
2. -- delete the primary key constraint and remove the index constraint on the primary key queried in [1], for example, PK _ person _ 117F9D94. Remove the primary key constraint from the primary key field. This field is not the primary key.Alter table person drop constraint PK _ person _ 117F9
* (Unitsinstock+unitsonorder) from Products
In the example above, if there is a "unitsonorder" value of NULL, then the result is null. Microsoft's ISNULL () function is used to specify how NULL values are handled. NVL (), Ifnull (), and coalesce () functions can also achieve the same result. Here, we want the NULL value to be 0. The following, if "UnitsOnOrder" is null, is not conducive to the calculation, so if the value is null then ISNULL () retu
Transaction Processing Mechanism in SQL sp_lock2Version: SQLServer7.02000Createdby: Alexander chigrikwww.mssqlcity.com
Transaction Processing Mechanism in SQL sp_lock2Version: SQL Server 7.0/2000 Created by: Alexander Chigrikhttp: // www.MSSQLCity.com/-all about ms SQL (SQL
Artificial Intelligence automatic SQL optimization tools-SQLTuning for SQL Server, SQL-sqltuning
In response to this situation, the artificial intelligence automatic SQL optimization tool came into being. Now I will introduce this tool: SQLTuning for SQL Server.
1.
First of all, the so-called SQL dynamic and static, refers to when SQL statements are compiled and executed, both are used in SQL embedded programming, which is referred to as embedded refers to the SQL statement embedded in the high-level language, rather than the type of microcontroller embedded programming.In a high
Tags: style blog http color using strongSum is the standard SUM function in an SQL statement, and the SUM function returns null if there are no records that match the criteria.But in most cases, we want it to return 0 instead of NULL if the condition record is not met, so we can use the following method, for example:SELECT COALESCE (SUM (name), 0) from the person WHERE ID > 0Okay, so you don't have to bothe
: COALESCE (Expression,value1,value2......,valuen)Instance:Select F_name,f_csrq,coalesce (F_CSRQ, ' 2015-10-10 ') as an important periodFrom t_studentarchives where f_name = ' 11 '(if F_CSRQ is null, the important period is 2015-10-10; otherwise, the important period is F_CSRQ)Select F_name,f_csrq,f_zz,coalesce (f_csrq,f_zz, ' 2015-10-10 ')As important period fro
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.