May 30, 2008 at 9:05 am
DECLARE
@intCurrentRowId INT,
@intMaxRowId INT,
@fname VARCHAR(100),
@lname VARCHAR(100)
SELECT @intMaxRowId = MAX(intRowId) FROM [#tab2]
SET @intCurrentRowId = 1
WHILE(@intCurrentRowId<=@intMaxRowId)
BEGIN
SELECT @fname=fname , @lname= lname FROM [#tab2] WHERE intRowId = @intCurrentRowId
IF(@fname IS NULL)
BEGIN
INSERT INTO #TAB3
SELECT @lname
END
ELSE
IF(@lname IS NULL)
BEGIN
INSERT INTO #TAB3
SELECT @fname
END
ELSE
BEGIN
INSERT INTO #TAB3
SELECT @lname+'.'+@fname
END
SET @intCurrentRowId = @intCurrentRowId +1
END
INSERT INTO #TAB3
SELECT ISNULL(SUBSTRING(lname,1,1),'')+fname FROM #tab2
May 30, 2008 at 9:16 am
whats the problem in the script?
May 30, 2008 at 9:18 am
check urinbox
May 30, 2008 at 9:40 am
Please post your question so that we can try to help you.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply