Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

for my application in a table called Mytable having ID column.

i want to insert 1 to 9999 into that ID column
Posted
Comments
Thomas Daniels 20-Oct-12 8:46am    
Ok, so do that.
Where you're stuck?
OriginalGriff 20-Oct-12 10:05am    
Where are you stuck, and (more to the point) why do you want to do this?
Just setting the ID column for 9999 rows doesn't do much that is useful, unless there is other data involved.
Sandeep Mewara 20-Oct-12 13:42pm    
And the issue is?

1 solution

You would need to define and execute a stored procedure (assuming you want to do this on the server, not the client).

If id is AUTOINCREMENT

SQL
CREATE PROCEDURE initiaize_id()
BEGIN
  DECLARE v1 INT DEFAULT 0;

  WHILE v1 < 10000 0 DO
    INSERT INTO MyTable (id) VALUES (null);
    SET v1 = v1 + 1;
  END WHILE;
END;

otherwise
SQL
CREATE PROCEDURE initiaize_id()
BEGIN
  DECLARE v1 INT DEFAULT 0;

  WHILE v1 < 10000 0 DO
    INSERT INTO MyTable (id) VALUES (v1);
    SET v1 = v1 + 1;
  END WHILE;
END;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900