SQL string Substitution handler function
Create function Dbo.regexreplace(@source varchar (5000),--Original string@regexp varchar (1000),--Regular expression@replace varchar (1000),--Replacement value@globalreplace bit = 0,--whether it is a global replacement@ignorecase bit = 0-is the size ignored?)Returns varchar (1000) ASBeginDECLARE @hr integerDECLARE @obj
Tags: set item char string length SQL out first fetch stringRequirement: The contents of the middle part of the 2nd to 3rd comma need to be intercepted in the actual project Scheme: declare @str nvarchar (50);Set @str = ' 11,222,3333,44444 ';Select @str as ' string 'Select Len (@str) as ' character length 'Select Charindex (', ', @str, 1) as ' the index value of
If the settings.settings file is automatically generated in the class library after you add LINQ to SQL and the database server is connected, the App. Config file is used to store the connection string (figure I)If you want to modify the connection string, which one or all of them should be modified? After my research found that the simplest only need to modify d
Only SQL functions can be used in a SELECT statement to manipulate fields (linked SQL Server).
Select field 1 from Table 1 where field 1. IndexOf ("cloud") = 1;
The reason this statement is not correct is that the indexof () function is not a SQL function, and it can be changed to a SQL corresponding function.
Left
--
Ms SQL server2k string splitting and merge processing code
-- Code for string splittingCreate Function f_splitstr (@ S varchar (8000), -- string to be split@ Split varchar (10) -- Data Separator) Returns tableAs-- Select top 8000 id = identity (INT,) into DBO. tb_splitstr -- auxiliary table used by the
SQL string function Encyclopedia, including many such as go to the space function to take a substring function string comparison function string manipulation function data type conversion function Date functionAnd so on the operation has a detailed description ah.Go to the Space function1, LTrim () The
')--error returned 0 --2. Type conversions:--Data type conversion cast convert--cast writes the converted value + as + the type converted toSelect CAST (1.999 as int)Select CAST (1.56656 as varchar )Select CAST (1.3996646 as Decimal (18,2))Select cast (CAST (' 1.5656 ' as Decimal (18,2) as int)Select CAST (' 1.5656 ' as Decimal (18,2))The --convert parameter 1 is the type that needs to be converted, and parameter 2 is the value that needs to be convertedSelect CONVERT (int, ' a ')Select CONVERT
SQL string Split Split function
Splits a string with the specified character.
Idea: 1, first compute the index of the specified split character in the string,
2. Then split the string again.
The SQL code is as follows:
declar
Tags: oracle San method font. com span table Concat SelectSometimes, we need to concatenate the data obtained from different fields. Each database provides a way to achieve this:
Mysql:concat ()
Oracle:concat (), | |
SQL Server: +
The syntax for CONCAT () is as follows: CONCAT (String 1, String 2, Stri
The following lists commonly used SQL string processing functions. Now let's take a look at the absolute value nbsp; SQL: selectabs (-1) value nbsp; o: selectabs (-1) valuefromdual nbsp; 2. round (large) nbsp; s: selectceiling (-1.001) value nbsp; o: selectceil (-1.001) v lists commonly used SQL
specified number of characters starting from the left-hand side of the string.Parameterscharacter_expressionA character or binary data expression. Character_expression can be constants, variables, or columns. Character_expression must be a data type that can be implicitly converted to varchar. Otherwise, use the CAST function to explicitly convert the character_expression.Integer_expressionis a positive integer. If integer_expression is negative, an empty s
CHARINDEX: Checks if a character (string) is contained in another string, and returns the starting position of the specified expression in the string.PATINDEX: Checks if a character (string) is contained in another string, returns the starting position of the first occurrence of a pattern in the specified expression, o
Tags: MyBatis pass the argumentUsed to hibernate, and then replaced by MyBatis will encounter some abnormal problems, as the following error prompt, with the MyBatis query, pass in a string argument, and when judged, the error is reportedThere is no getter for property named ' Modulecode ' in ' class java.lang.String DAO Layer Invocation Mode/* DAO Layer Query * /@Overridepublic listCommon error notation:XML Mapping SQLNeed to be modified to:Whatev
The SQL String concatenation function uses CONCAT () in the SQL String concatenation function. The CONCAT () syntax is as follows: CONCAT (string 1, string 2, string 3 ,...): concatenat
In a SELECT statement, only SQL functions can be used to operate fields (link to SQL Server ),Select Field 1 from table 1 where field 1. indexof ("Cloud") = 1;This statement is incorrect because the indexof () function is not an SQL function. You can change it to the corresponding SQL function.Left () is an
SQL Server String splitting implementation statement. For details, refer.
SQL Server String splitting implementation statement. For details, refer.
The Code is as follows:
--> Title: generate a sequence number.
--> Author: wufeng4552
--> Date: 09:02:08
If object_id ('f _ split ') is not null drop function f_split
By default, SQLServer is case insensitive. For example, userNamejesse and userNameJESSE have the same results. When the password is verified, it may be case sensitive to the string and some processing is required. Two methods are introduced: method I: Convert to binary and then compare, because the case-sensitive ASC code is different. Example: select * fromT _
By default, SQL Server is case insensitive. Fo
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.