Suppose you have a table similar to the following:
table: m_tbl
ID AreaCode
--- ---
1 0000000001
2 0000000002
3 0000000003
4 0000000021
5 0000000044
. .
. .
. .
I would like to use these data to re-register 50 billion (50,000,000,000) data while re-shifting my ID.
What kind of SQL statement would this be?
sql sql-server
Why don't you run INSERT~SELECT~
10 times?
INSERT INTO other (AreaCode)
SELECT AreaCode FROM m_tbl
The above is omitted with the assumption that the ID
is in the IDENTITY
column, but if necessary, please add it appropriately.
If you also want to write the recurring part in Transact-SQL, use the WHILE
statement to:
DECLARE
@int=1;
BEGIN
WHILE@i<=10
BEGIN
INSERT INTO other (AreaCode)
SELECT AreaCode FROM m_tbl;
SET@i=@i+1;
END
END
© 2024 OneMinuteCode. All rights reserved.