Results 1 to 3 of 3

Thread: sql procedure

  1. #1
    Join Date
    Jul 2003
    Location
    porto - Portugal
    Posts
    74

    Unanswered: sql procedure

    Hi people,

    Someone could just tell me how i can create an table with just the first 100 000 rows of another table. The two tables have the same columns.

    Thanks,
    Rui

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: sql procedure

    In the sample database, if dept2 is 'like' department,

    insert into dept2
    select DEPTNO,
    DEPTNAME ,
    MGRNO ,
    ADMRDEPT ,
    LOCATION from (
    select row_number() over() as rownum,
    DEPTNO,
    DEPTNAME ,
    MGRNO ,
    ADMRDEPT ,
    LOCATION
    from department d
    ) as b
    where b.rownum < 2

    will select 1 row from department and insert into dept2

    HTH

    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jul 2003
    Location
    porto - Portugal
    Posts
    74

    Re: sql procedure

    Thanks!
    Originally posted by sathyaram_s
    In the sample database, if dept2 is 'like' department,

    insert into dept2
    select DEPTNO,
    DEPTNAME ,
    MGRNO ,
    ADMRDEPT ,
    LOCATION from (
    select row_number() over() as rownum,
    DEPTNO,
    DEPTNAME ,
    MGRNO ,
    ADMRDEPT ,
    LOCATION
    from department d
    ) as b
    where b.rownum < 2

    will select 1 row from department and insert into dept2

    HTH

    Sathyaram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •