Hi @Rahul Polaboina
As experts explained above, PARSENAME just returns the specified part of the specified object name which is [Server name].[Database name].[Schema name].[Object name]
separated by .
(1 = Object name; 2 = Schema name; 3 = Database name; 4 = Server name; )
Note: Each part of the 'object_name' string is type sysname which is equivalent to nvarchar(128) or 256 bytes. If any part of the string exceeds 256 bytes, PARSENAME will return NULL for that part as it is not a valid sysname.
but I am expecting to return 'HONG, ELSIE W.'
If you want to include .
in your desired result, PARSENAME is not a good choice.
Try this:
DECLARE @STRING VARCHAR(200)='HONG, ELSIE W..9110'
SELECT LEFT(@STRING,LEN(@STRING)-CHARINDEX('.',REVERSE(@STRING)))
Output:
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.