TSQL - To Split Key=Value string into Key and value Columns

If we want to split a string which is like Key=value format then apply the below query to get the Key and Value strings seperately .

declare @inputData varchar(Max) = 'Customer Name=Surendra Thota'
select SUBSTRING(left(@inputData,Len(@inputData)),0,charindex('=',@inputData)) as [Key],SUBSTRING(left(@inputData,Len(@inputData)),(charindex('=',@inputData)+1),40) as Value



Comments

Popular posts from this blog

SSAS : A connection cannot be made to redirector. Ensure that 'SQL Browser' service is running. (Microsoft.AnalysisServices.AdomdClient). + Solution

SSIS Error : Unable to infer the XSD from the XML file. The XML contains multiple namespaces