top of page

Criando uma tabela com números SQL Server



IF OBJECT_ID('dbo.Numbers') IS NOT NULL DROP TABLE dbo.Numbers;


CREATE TABLE dbo.Numbers (Number INT PRIMARY KEY);


WITH Tally (N) AS (

SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1

FROM sys.objects s1 CROSS JOIN sys.objects s2

)

INSERT INTO dbo.Numbers (Number)

SELECT N

FROM Tally

WHERE N <= 10000; -- Ajuste conforme necessário



select * from Numbers



Resultado:


Posts recentes

Ver tudo
bottom of page