DECLARE @str varchar(50)='Hello, world'; /* SQL SERVER QUERY TO SPLIT STRING FROM COMMA AND GET LEFT AND RIGHT PART */
SELECT LEFT(@str, CHARINDEX(',', @str)-1) as LeftPart, RIGHT(@str, LEN(@str)-CHARINDEX(',', @str)) as RightPart;
Error is
Must declare the scalar variable "@str"
why it is coming ? if any one know tell me friends


Chandu KumawatRank #1,449 · 1.1K reputationPosted Feb 9, 2016, 10:26 PM EST
Sujeet SumanRank #790 · 2.9K reputationPosted Feb 9, 2016, 10:44 PM EST
Raja TRank #685 · 3.5K reputationPosted Feb 9, 2016, 11:31 PM EST
Prasad Anumolu14 reputationPosted Feb 10, 2016, 8:57 AM EST
Raja TRank #685 · 3.5K reputationPosted Feb 10, 2016, 7:03 PM EST