Results 1 to 2 of 2

Thread: Copy rows in SQL SERVER Table

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    6

    Copy rows in SQL SERVER Table

    I have a SQL Server Table that has a column with a number in it. Is there a way that I can query that table to find out what the number is and copy the rows that number of times in a new table.

  2. #2
    New Member
    Join Date
    Apr 2004
    Location
    Corona, Ca
    Posts
    4
    Well, the simple method would be to use stored procedure that has a variable you can populate with the number from your table. Here's an example of the T-SQL Code you might use.

    DECLARE @iNumber Integer

    --Initialize variables

    SELECT @iNumber = {Your Column Name}
    FROM {Your Table Name}
    WHERE {Method you are going to use to identify the row you want to use (Example SELECT CustID From Customer Where Name = 'Jones')}

    From this point you could use this variable to run the stament(s) necessary to populate your second table...

    This stored procedure could then be called from your VB app.

    My question is why you would want multiple rows of the same data in a table? This sort of goes against the rules of database normalization.
    Lou Davis

Posting Permissions

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



Click Here to Expand Forum to Full Width