String functions and data type conversion functions

Source: Internet
Author: User
Tags rtrim


--string function. Returns the ASII code of the leftmost letter of the string
Print ASCII (' ABCDE ')
Print ASCII (')
Print char (--ASCII) conversion between code and characters
--*charindex The starting index of the corresponding character segment in the lookup string, starting at 1
Print charindex (' de ', ' ABCDEFG ')
--concat string Links
print ' abc ' + ' de '
--
Select SOUNDEX (' Hello ')
Select SOUNDEX (' hell ')
Select Soundex (' Hella ')
--diference returns the similarity of a string
Select difference (' Hello ', ' hell ')
--space help you print out the blanks
Select ' A ' +space (Ten) + ' B '
--*left intercepts the string at the beginning of the specified length. Right truncate end specifies length.
Select Left (' Abcdefgh ', 3)
Select Right (' Abcdefgh ', 3)
--*len the space to calculate the length, returning an integer.
Select LEN (' abc ')
--*lower uppercase to lowercase. Upper lowercase to uppercase
Select LOWER (' ACDE ')
Select UPPER (' ABCDE ')
--*ltrim Remove the front space. RTrim Remove Right space
Select LTRIM (' A A ')
Select RTRIM (' A A ')
--Find the first alphabetical index of the matching wildcard character segment that matches the criteria, like
Select PATINDEX ('%de% ', ' abcdef ')
--*replace find replacement, three parameters. 1. Target string 2. Character segment to check 3. Which character segment to replace
Select REPLACE (' abcdefabhhhhhhh ', ' ab ', ' @# ')
--replicate copies the specified number of times and stitching it back into a string
Select REPLICATE (' Dee ', 3)
--*reverse flipping A string
Select REVERSE (' ABCDE ')
--str float type, after interception, converted to string type
Select STR (1112.12345,3,2)
--stuff Delete a specified length of Word string from the specified position before inserting a new character segment
Select STUFF (' Abc123hhhhhh ', 4,15, ' abc ')
--*substring Intercept string
Select SUBSTRING (' ABCDE ', 4,2)
--Data type conversion function
--cast function
Select CAST (' 123 ' as int)
--convert function, which is the opposite of cast
Select CONVERT (int,12.3)

String functions and data type conversion functions

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.