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

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -