inserting values from same table

From: Pascal Schmidt-Volkmar (nospam_at_schmidt-volkmar.com)
Date: 01/21/04

  • Next message: Dennis: "Re: Re: Login form is not responsive when connecting to the DB"
    Date: Wed, 21 Jan 2004 12:32:16 +0100
    
    

    Hi there,

    I need to duplicate entries of a table apart from the primary key.

    What I need is a simple sql statement that does the job. Something like:

    CREATE PROCEDURE COPY_UMFTYP @UMFRAGETYP varchar(50), @UMFRAGETYPID int
    AS
    DECLARE @MAXNR int
    SET @MAXNR = (SELECT MAX(TYP_ID)+1 FROM T_TYP)
    IF @MAXNR IS NULL SET @MAXNR = 1

    INSERT INTO T_TYP (TYP_TYPNAME, TYP_ID) VALUES (@UMFRAGETYP, @MAXNR)
    INSERT INTO T_ATYP (ATYP_TYP_ID, ATYP_NR, ATYP_AUSSAGE, ATYP_FAKT_ID,
    ATYP_NEGATIV)
     VALUES (@MAXNR, (SELECT ATYP_NR, ATYP_AUSSAGE, ATYP_FAKT_ID, ATYP_NEGATIV
    FROM T_ATYP WHERE ATYP_TYP_ID = @UMFRAGETYPID))

    Unfortunately, this statement does not work, but what do I have to change to
    get it running?

    Thanks,

    Pascal


  • Next message: Dennis: "Re: Re: Login form is not responsive when connecting to the DB"

    Relevant Pages

    • Re: subform records
      ... open the Immediate Window. ... Copy the SQL statement there, and paste it into SQL View in a new query. ... tblSet, with SetID primary key, and OrderID foreign key. ... Dim strSql as String ...
      (microsoft.public.access.formscoding)
    • Re: DISTINCTROW
      ... the sql statement is querying 2 tables and 1 stored query. ... but these are not unique indexes. ... tblB does not have primary key and does not have index. ...
      (microsoft.public.access.queries)
    • Re: subform records
      ... open the Immediate Window. ... Copy the SQL statement there, and paste it into SQL View in a new query. ... Allen Browne - Microsoft MVP. ... tblSet, with SetID primary key, and OrderID foreign key. ...
      (microsoft.public.access.formscoding)
    • Re: Slow GROUP BY
      ... ' 'create primary key ... PunchList INNER JOIN Lot ON PunchList.LotId = Lot.Id INNER JOIN PunchItem ON ... the exact schema of the parent and child table ... your exact SQL statement that includes the GROUP BY ...
      (microsoft.public.dotnet.framework.compactframework)
    • Re: SQL Server Data Log not in order? Help please
      ... your statement "there is no primary key" is quite scary. ... (Reverse address to reply.) ... >used SQL statement and ADO API to execute that SQL statement. ... > 2) ID_1 with type int ...
      (microsoft.public.sqlserver.programming)