Quantcast
Channel: CameTooFar
Viewing all articles
Browse latest Browse all 45

Populate dummy records in SQL Server

$
0
0

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
UNIONall
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.


Viewing all articles
Browse latest Browse all 45

Trending Articles