/****** Object:  StoredProcedure [dbo].[temp_remap_dzialy_rozdzialy]    Script Date: 05/25/2009 10:06:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[temp_remap_moduly_grzbiety]
	@tytul nvarchar(100),
	@modul nvarchar(100)
	
AS
BEGIN
	
DECLARE @tytul_id INT
DECLARE @grzbiet_id INT

SELECT @tytul_id=Id FROM dbo.[Lista Tytu³ów] WHERE Symb=@tytul



SELECT @grzbiet_id=S.Id FROM dbo.[NAZWY MODU£ÓW] M
INNER JOIN dbo.SekcjeModuly SM ON SM.ModulId=M.Id
INNER JOIN dbo.Grzbiety S ON S.Id=SM.SekcjaId
WHERE S.TytulId=@tytul_id AND S.Active=1 AND M.Active=1 AND M.MOD_TYP=@modul

Update dbo.Reklama
SET Grzbiet=@grzbiet_id
WHERE [Tytu³]=@tytul AND MOD_TYP=@modul

RETURN

END
