Hi i have 10 tables that all have an int, no relationships, column called MemberID. I would like to add memberID from 1 to 2000 in all 10 tables. Is there a way to do this while loop based for all tables of type 'user' ?
You could use dynamic sql and execute sp_foreachtable, but with ten tables, it would probably be faster to just copy and paste an insert statement ten times.
Code:
DECLARE @i INT
SELECT @i = 1
WHILE @i <= 2000
BEGIN
INSERT INTO Table1 (MemberID) SELECT @i
INSERT INTO Table2 (MemberID) SELECT @i
etc...
SELECT @i = @i + 1
END
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.