CREATE PROCEDURE dbo.ep_HDC_ImportCADKusovnik
    @Zakazka NVARCHAR(15)=N'',
    @Stanice NVARCHAR(15)=N''
AS

SET NOCOUNT ON

/* v pluginu je
CREATE TABLE #TabCADKusovnik
  (ID INT IDENTITY(1,1) NOT NULL, NovaKarta BIT DEFAULT 0, Pozice INT, IDKmen INT, CisloDilce NVARCHAR(100), Nazev NVARCHAR(100), Mnozstvi NUMERIC(19,6) DEFAULT 0.0,
   Zpracovani NVARCHAR(200), Vyrobce NVARCHAR(200), Norma NVARCHAR(200), PU NVARCHAR(200), Material NVARCHAR(200), Tloustka NUMERIC(8,2) DEFAULT 0.0
  )
*/

IF OBJECT_ID(N'tempdb..#TabCADKusovnik', 'U') IS NULL
 RETURN

DECLARE
 @novaKarta BIT,
 @pozice INT,
 @idKmen INT,
 @cisloDilce NVARCHAR(100),
 @nazev NVARCHAR(100),
 @mnoz NUMERIC(19,6),
 @zpracovani NVARCHAR(100),
 @vyrobce NVARCHAR(100),
 @norma NVARCHAR(200),
 @pu NVARCHAR(200),
 @material NVARCHAR(200),
 @tloustka NUMERIC(8,2)


DECLARE c CURSOR LOCAL FAST_FORWARD FOR
 SELECT NovaKarta, Pozice, IDKmen, CisloDilce, Nazev, Mnozstvi, Zpracovani, Vyrobce, Norma, PU, Material, Tloustka
  FROM #TabCADKusovnik ORDER BY ID
OPEN c
WHILE (1=1)
 BEGIN
  FETCH NEXT FROM c INTO @novaKarta, @poizce, @idKmen, @cisloDilce, @nazev, @mnoz, @zpracovani, @vyrobce, @norma, @pu, @material, @tloustka
  IF (@@FETCH_STATUS<>0) BREAK



 END
CLOSE c
DEALLOCATE c
