MsSql Store Procedure

Last post 08-27-2008 9:34 PM by Matt-dot-net. 1 replies.

Sort Posts:

  • MsSql Store Procedure

    08-27-2008, 9:18 PM
    • Member
      point Member
    • mohfeza
    • Member since 06-22-2008, 4:57 AM
    • Posts 35

     how can i insert data into temp table from 2 diferent tables, and get data from temp table.

    My following code giving output just from 2nd table. how can i append 2nd table data("new_BannerList" table) into temp table after inserting

    1st table data("WDI_T_PartnerRegistration" table).

     

    ALTER PROCEDURE dbo.GetAllAdBanner
    AS
    BEGIN

    CREATE TABLE #TempTable 

      UserName VARCHAR(100), 
      Banner VARCHAR(200) 
    )

    INSERT INTO #TempTable
    Select PR.UserName AS UserName, PR.Banner AS Banner from  WDI_T_PartnerRegistration PR ,WDI_M_Users MU where MU.UserId=PR.UserName
    and MU.UserType=3 and PR.Status=1 and PR.Banner!= '' 
    Select  NBL.PartnerID AS UserName, NBL.Banner AS Banner from new_BannerList NBL where NBL.Banner!=''

    SELECT * FROM #TempTable



    drop table #TempTable

     
    END
     

     

     

    Thanks,

    Mohfeza

    m,khatoon
  • Re: MsSql Store Procedure

    08-27-2008, 9:34 PM
    • Contributor
      4,008 point Contributor
    • Matt-dot-net
    • Member since 06-09-2007, 12:00 PM
    • Kentucky
    • Posts 772
    ALTER PROCEDURE dbo.GetAllAdBanner 
    AS
    BEGIN
    
    
    Select PR.UserName AS UserName, PR.Banner AS Banner 
    from  WDI_T_PartnerRegistration PR ,WDI_M_Users MU 
    where MU.UserId=PR.UserName and 
          MU.UserType=3 and 
          PR.Status=1 and 
          PR.Banner!= ''  
    
    UNION 
    
    Select  NBL.PartnerID AS UserName, NBL.Banner AS Banner 
    from new_BannerList NBL where NBL.Banner!=''
    
    
     
    END
    Filed under: ,
Page 1 of 1 (2 items)