Populate dummy records in SQL Server

Last day, I was playing with paging in SQL Server and had to create some test data to test the same. Here goes the script to generate test data.

DECLARE @UserTable TABLE (Id int, Name nvarchar(150))
 
;WITH cte AS
(
    SELECT 1 Id
    UNION all
    SELECT Id + 1
    FROM cte WHERE   Id + 1 <= 100000
)
 
INSERT INTO @UserTable(Id,Name)
    SELECT Id, Concat('Name_', convert(int, convert (varbinary(4), NEWID(), 1))) AS Name FROM cte c 
    OPTION (MAXRECURSION 0)
 
 
SELECT u.Id, u.Name
    Into DemoUser
    FROM    @UserTable u

 

Hope this helps.

Pingbacks and trackbacks (1)+

Add comment

Loading