Combine 2 selects

  • DECLARE @EmployeeID nvarchar(1000)

    DECLARE @FiscalYear nvarchar(1000)

    SET @EmployeeID = '101,102,103,104,105'

    SET @FiscalYear = '2013,2014'

    SELECT Data FROM dbo.Split(@EmployeeID, ',')

    SELECT Data FROM dbo.Split(@fiscalyear, ',')

    _______________________________________

    This is part of a bigger project but I am stuck on this part. I get back 2 result sets

    Data Data

    101 2013

    102 2014

    103

    104

    105

    I wants to insert the results in a new table 2 columns and get the rsults below.

    New Table

    ID Fiscal Year

    101 2013

    101 2014

    102 2013

    102 2014

    103 2013

    103 2014

    104 2013

    104 2014

    105 2013

    105 2014

  • That's fairly easy

    SELECT e.Data AS ID, y.Data AS FiscalYear

    FROM dbo.Split(@EmployeeID, ',') e CROSS JOIN dbo.Split(@fiscalyear, ',') y

    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
  • TY that worked I dont know why that was causing me such a problem. Now that I see the answer it was easy.

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

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