sql server - SQL create table with integers -
I should have an integer (1,2, ...) with a column with one column in a database because it Some help to join
I came up with a solution using a loop. Is there a more efficient way to create such a table?
My solution
create table #NUM (NUM int) DECLARE @i int = 1 WHILE @ i & lt; 10000 BEGIN INSTERT #Temp SELECT @i SET @i = @ I + 1 END
SELECT row_number () more than (sequence by message_id) num in #Table from sys.messages
Comments
Post a Comment