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.
Printable View
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.
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.