MS SQL server has a function PARSENAME ( 'object_name', object_piece) .
Function has two parameters:
Object_name
Object name search. That is: the name of the database server name the owner of the object name.
Object_piece
Is the type of object retrieval. A value of 1 to 4.
For example, to store incoming custom function or procedure table name:
the TABLE_CATALOG . The TABLE_SCHEMA . . TABLE_NAME COLUMN_NAME
dynamic operation of the data table.
For columns:
DECLARE @str NVARCHAR(MAX) = N'testdb.dbo.table_part.qty' SELECT PARSENAME(@str,4) AS [TABLE_CATALOG], PARSENAME(@str,3) AS [TABLE_SCHEMA], PARSENAME(@str,2) AS [TABLE_NAME], PARSENAME(@str,1) AS [COLUMN_NAME] GO
Another presentation, the definition of a table variable to store some random add IP address:
Then SELECT table, and use the ORDER BY sort:
This sort result is not what we want, it's just the size for each period of the first digital sort.
This is why, because these IP address, not a standard IP address.
The IP address is converted to IP standard, refer to this "
converted to standard IPv4 format
"
https://www.cnblogs.com/insus/p/10958864.html
The above function, there are used
PARSENAME
line processing function.
;WITH cte_ips AS ( SELECT [IPv4],[dbo].[svf_ConvertToStandardIPv4]([IPv4]) AS [std_ip] FROM @ips ) SELECT [IPv4],[std_ip] FROM cte_ips ORDER BY PARSENAME([std_ip],4), PARSENAME([std_ip],3), PARSENAME([std_ip],2), PARSENAME([std_ip],1)