taking null

  • 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

  • whats the problem in the script?

  • check urinbox

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply