DECLARE @STRVALUE NVARCHAR(MAX),
@CREATEDDATE DATETIME,
@STANTANCEVALUE NVARCHAR(MAX),
@COUNT INT=0,
@JOBCODE NVARCHAR(50)='JOB00123654',
@DATE DATETIME=GETDATE(),
@NAME NVARCHAR(50)='Ramkumar',
@JOBID INT;
CREATE TABLE #TempContentSplitValue (ITEMS NVARCHAR(200))
SELECT @JOBID = i.Id FROM JobHeader_TBL i WHERE Id=1201;
IF EXISTS (SELECT 1 FROM JobHeader_TBL WHERE Id=@JOBID)
BEGIN
SELECT @STRVALUE= Description from ContentTemplate_TBL where Id=1
INSERT INTO #TempContentSplitValue SELECT * FROM dbo.split(@STRVALUE, '_')
SET @STRVALUE=''
DECLARE db_contentcursor CURSOR FOR SELECT ITEMS FROM #TempContentSplitValue
OPEN db_contentcursor
FETCH NEXT FROM db_contentcursor
INTO @STANTANCEVALUE
WHILE (@@FETCH_STATUS = 0)
BEGIN
SET @STRVALUE += @STANTANCEVALUE + 'JOB00123654'
SET @COUNT += 1
SELECT @COUNT
FETCH NEXT FROM db_contentcursor INTO @STANTANCEVALUE
END
CLOSE db_contentcursor
DEALLOCATE db_contentcursor
DROP TABLE #TempContentSplitValue
SELECT @STRVALUE
END