Label:
Turn from: http://www.2cto.com/database/201209/154045.html Oracle
the REGEXP_SUBSTR function Instructions for using the REGEXP_SUBSTR function in Oracle: The topic is as follows: In Oracle, a statement is implemented to split ' 17,20,23 ' into a collection of ' 17 ', ' 20 ', ' 23 '. The REGEXP_SUBSTR functions are formatted as follows: function regexp_substr (String, pattern, position, occurrence, modifier) __srcstr nbsp : strin
; 7. Rounding The ROUND () function is also used for numerical rounding. SELECT ROUND (56.670) roundValue1,
ROUND (56.671) roundValue2,
ROUND (-56.670) roundValue3; 8. Find the sine value SELECT SIN (56.67) Sinvalue; 9. Calculate Cosine value SELECT COS (56.67) Cosvalue; 10. To find the sine value of the inverse SELECT 1 / 56.67 ,
ASIN (1/56.67) Asinvalue; 11. To find the inverse cosine value SELECT 1 / 56.67 ,
ACOS (1/56.67) Acosvalue; 12. To find the tangent val
Solution for slow SQL query caused by custom functions, function SQL
During the report process, one report queries the exchange rate of the corresponding currency, and the exchange rate is in another table, the condition for querying the exchange rate is to query the exchange rate of the previous month of the statistical date in the Exchange Rate Table based on
used when creating views3. SQL ProgrammingFirst, define the variable: DECLARE @ variable name data typeExample: declare @a intVariable assignment: SET @ variable name = valueSet @a=5Select @a--Print directly in the results boxSelect @a=10--Do not output only assign valuesPrint @a--Printing in a message boxExample:DECLARE @price decimal (10,4)Select @price = AVG (price) from carprint ' average price for all cars: ' +cast (@price as varchar (20))Cast f
as follows:
Value
Abbreviation (SQL Server)
Access and ASP
Description
Year
Yy
yyyy
Year 1753 ~ 9999
Quarter
Qq
Q
Quarter 1 ~ 4
Month
Mm
M
Month 1 ~ 12
Day of the Year
Dy
Y
The number of days in a year, the first day of the year 1-366
Day
Dd
D
Day, 1-31
Weekday
Dw
W
The number of days
1. Case when ... Then ...var from inch context. Products Selectnew { = P.productid, = p. ProductName, 0" Yes " " no " };SELECT [Extent1].[ProductID] as [ProductID], [Extent1].[ProductName] as [ProductName], Case when([Extent1].[UnitsInStock] > 0) ThenN'is a' ELSEN'No' END as [C1] from [dbo].[Product] as [Extent1]LINQ series: LINQ to SQL Transact-
Detach the database as follows:use master go sp_detach_db ‘mydb‘ go
Then, copy the data and log files from the current location (D:\Mssql7\Data) to the new location (E:\Sqldata).
Reattach the databases that point to the files in the new location as follows:use master go sp_attach_db ‘mydb‘,‘E:\Sqldata\mydbdata.mdf‘,‘E:\Sqldata\mydblog.ldf‘ goUse sp_helpfile to confirm file location changes:use mydb go sp_helpfile go
How to move a SQL
]% ', ' RCRDSDDDDAADADFFDR ')Returns the position of the first occurrence of D in 4,[] in the string rcrdsddddaadadffdr.Select Patindex ('%[cd]% ', ' RCRDSDDDRDAADADFFDR ')Returns the position of c,d in one of the 2,[], returns the first occurrence of this position, C in this string where the position is 2, and D is 4, the result takes the first one.Select Patindex ('%[sd]% ', ' RCRDSDDDRDAADADFFDR ')Returns the position of c,d in one of the 4,[], returns the first occurrence of this position, s
6. Basic SQL sorting (date and time data types, conversion functions) and SQL data typesDate and Time Data Type
* System constant:
@ DATEFIRST (returns the current time)DATEADD
Increase time
Syntax: DATEADD (datepart, number, date)
Select DATEADD (YEAR, 2, '1970-11-2 ')
DATEDIFF
Distance between two dates
Select DATEDIFF (YEAR, '2017-7-18 ', '2017-11-2 ')
DATENAM
Single-record functions in SQL
1. ASCIIReturns the decimal number corresponding to the specified character;
SQL> select ASCII ('A') A, ASCII ('A') A, ASCII ('0') zero, ASCII ('') space from dual;
A A zero space
------------------------------------
65 97 48 32
2. CHRReturns the corresponding characters;
SQL> select CHR
Tags: research trace title ORM CSDN SQL Server Design example data Transferred from: Leo_wlcnblogsSQL Server functions explained by some common DLLsIf your SQL Server is installed in the C drive, the following path is the storage path of the corresponding SQL Server version of the common DLL SQL2005 C:\Program Files\Mi
T-SQL is the implementation of Microsoft SQL-3 standard in the relational database management system SQL Server, is the expansion of SQL, has the main characteristics of SQL, at the same time, language elements such as variables, operators,
Essentially, there is no difference. Only functions are as follows: only one variable can be returned. The stored procedure can return multiple objects. Functions can be embedded in SQL and called in select, but stored procedures cannot. The essence of execution is the same. There are many function restrictions. For example, you can only use table variables inste
Directory
Generate background (stored procedures already available, why use custom functions)Development historyConstituteHow to useApplicable scopeAttention mattersQuestionscontent
Generate background (stored procedures already available, why use custom functions)
Differences from stored procedures (meaning of existence):
1. The ability to use custom functions
A function is a subroutine composed of one or more statements. It can be used to encapsulate code for reuse.
System FunctionsGroupBuilt-in functionsTo perform operations on values, objects, and settings in SQL Server, and return information about them.
SQL Server basic functions:
1. String FunctionsLength and AnalysisDatalength (char_expr) returns the number of
sorted data, so its ranking is 4 + 1 = 5
To sum it up, over defines a set of rows that is a function that returns a unique value each time it is returned to the current row. In this example, the Rank function is used to return a ranking of the current row.
Other functions used in the over-over collocation
Aggregate functions-SUM, COUNT, MIN, MAX
Rank function-Rank, Dense_rank, Row_number, Ntile
Distri
I. Basic concepts:
SQL functions can contain any number of queries, but the function returns only the results of the last query (which must be select. In simple cases, the first row of the last query result is returned. If no row is returned for the last query, the function returns NULL. If you need this function to return all rows of the last SELECT statement, you can define the return value of the functi
First, the basic concept:
SQL functions can contain any number of queries, but the function only returns the result of the last query (which must be a select). In simple cases, returns the first row of the last query result. If the last query does not return any rows, the function returns a null value. If you need this function to return all the rows of the last SELECT statement, you can define the return
PostgreSQL tutorial (19th): SQL language functions, postgresqlsql
I. Basic concepts:
SQL functions can contain any number of queries, but the function returns only the results of the last query (which must be SELECT. In simple cases, the first row of the last query result is returned. If no row is returned for the last
) detailed Description All select Plus with (NoLock) resolves blocking deadlocks NOLOCK and READPAST are all handled when querying, inserting, deleting, and so on, how to deal with locked data records. However, it is important to note the limitations of NOLOCK and Readpast, and confirm that your business logic can tolerate the presence or failure of these records: NOLOCK may also display data that does not commit the transaction.READPAST will not show the locked line. Consider using NOLOCK in mo
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.