Q:
Ask an SQL 2000 sever question:
Select * From itemcode
Where code like '20140901'
How to Set code = 40101001
To code = 401-01-001
Currently, 666 codes are similar to 40101001
Which statement can be used to convert it to 401-01-001?
A:Update itemcode set code = Replace (Code, left (Code, 8), left (Code, 3) + '-' + substring (Code, 4, 2) + '-' + substring (Code, 6, 3) where code like '20140901'
Q:Replace (Code, left (Code, 8), left (Code, 3) + '-' +
What should I do if I need to filter the scores in the middle of an SQL string field? The following describes how to filter records of the central score of an SQL string field for your reference.
For example, there is a KKBH (bayonet number) field, which is a dictionary field (corresponding to the number field of anot
If you need to filter some of the values in the SQL string field, what should you do? Here's how to filter the records of some of the values in the SQL string field for your reference.
For example, there is a KKBH (card number) field, which is a dictionary field (a numbered field corresponding to another entity table
Tags: style io os using AR strong data Art spOnly SQL functions can be used to manipulate fields in a SELECT statement (linked to 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 an SQL function, so it can be changed to the corresponding function of SQL.Lef
There are many kinds of time types, and I only speak today (Util SQL String) three conversions betweenUtil--->string conversion:Import Java.util.Date;SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy/mm/dd"); Java.util.Date date=new Java.util.Date (); String str=sdf.format (date);
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 function.
Select Field 1 from table 1 where charindex ('cloud', Field 1) = 1;
String functions
, insert string)In a string, delete the character of the specified length and insert a new string at that location;ExampleSELECT STUFF (' ABCDEFG ', 2, 3, ' small movers ')Return: a small porter EFG7. Replace (Specify string, string to be replaced,
SqlServer removes string spaces and SQL Server strings
Speaking of removing spaces at the beginning and end of a string, you must be the first to think of the trim () function. However, this function is not available in sqlserver, but instead of ltrim () and rtrim () two functions. We can see that everyone knows what
in the actual project development, often according to the user in the Interface text box input information, go to the database to do fuzzy query. If you are using raw JDBC and SQL, you often need to escape the user's input, avoid SQL syntax errors generated, or prevent SQL injection. For example, the input of% and _ and ', you need to escape, because these 3 char
security architecture, hard coding of connection strings, etc., and is worth using.
SQL Native Client ODBC Driver
Standard secure connection
Copy Code code as follows:
Driver={sql Native Client}; Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword;
Are you using SQL Server Express? Please use the connection expres
Some time ago, we encountered this problem when performing a batch data review or deletion function:
Because the review or deletion operation is performed in the stored procedure, we plan to splice the primary key of the selected data into a string and upload it to the stored procedure for separation before processing.
In C # and JavaScript, there is a Split function that separates strings. It is assumed that there are similar functions in
is an integer value with a positive sign. 6, Datename () Datename (,) Returns the specified part of the date as a string in this section. specified by DatePart. 7, DATEPART () DATEPART (,) Returns the specified part of the date as an integer value. This section is specified by DatePart. DATEPART (dd, date) is equivalent to day (date) DATEPART (mm, date) equals month (date) DATEPART (yy, date) is equivalent to year (date) 8, GETDATE () Returns the cur
Recently, when I was writing a stored procedure, I found a problem about introducing parameters to the string SQL statements in the stored procedure.
See the following example:
declare @count intselect @count=count(*) from student where Name in ('Chamy','Jundy')print @count
If we want to introduce parameters after In the above sentence:
It must be written as follows:
declare @count intdeclare @Names nvarcha
How to determine whether a SQL string contains characters
In SQL, we can use many methods to determine whether a string contains a string, such as like, replace, and charindex functions. The following describes how to determine whether a
("Adodb.connection");Third, the connection string (all connection strings are case insensitive, and the keys and values are not distinguished):Provider=sqloledb.1//The key is used to indicate the database type that provides the database service, and the value is not the same for different databases. Other types please refer to: http://www.w3school.com.cn/ado/prop_conn_provider.asp Integrated security/trusted=true[yes,no,false,sspi]//when the key is y
SQL parse string added to temporary table SQL stored procedure in parameter input workaroundAdding string parsing to a staging tableSELECT * into #临时表 from dbo. Func_splitonecolumntabel (' 001,gf ', ', ')SELECT * FROM table where ID in (SELECT ID from temp table)Create function [dbo]. [Func_splitonecolumntabel](@str nv
SQL Custom Function Split delimited stringF_split: Splitting a string into a data table Create FUNCTION [dbo]. [F_split] (@SplitString nvarchar (max),--source string @Separator nvarchar (10) = "--delimited symbol, default to space) RETURNS @SplitStringsTable table-Output datasheet ([id] int identity (), [value] nvarchar (max)) as BEGIN DECL is @CurrentIndex
Tags: SQL Server Multi-table search stringSQL Server Multi-table search stringWe described a number of SQL Server articles earlier, today we mainly introduce the SQL Server under the condition of not knowing the table name of the search string, we all know that there will be more than one database under the time of the
I. NET Framework Data Provider for SQL ServerType:. NET Framework Class LibraryUse: System.Data.SqlClient.SqlConnectionManufacturer: Microsoft
1. Standard secure connection
Copy Code code as follows:
Data Source = myserveraddress;initial Catalog = myDataBase; User Id = MyUserName; Password = mypassword;
Use the server name \ Instance name as the connection to specify the data source for the SQL
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.