Posts

Showing posts with the label Remove the string

Remove the string after a particular character(Making Sub string)

Remove the string after a particular character(Making Sub string) This code may be used where we want to remove a the string after a particular character. Example :- Suppose your column have like this - ID Name 1 MNIT,Jaipur 2 GVSET,JAipur 3 MSJ,Bharatpur etc. Now you want to remove the cities name from this column. You can do this by simply using this code -         UPDATE Table_Name SET Name= dbo.substr(Name) Function should be look like this-            CREATE FUNCTION dbo.substr(@string nVARCHAR(MAX))      RETURNS nVARCHAR(MAX)          BEGIN                   DECLARE @SpaceIndex TinyInt                   SET @SpaceIndex = CHARINDEX(',', @string)           ...