Sometimes ago, I needed to insert bulk data to one of my table. I was needed a loop which will insert the data one by one. Previously I did that using a console application. But now I find a better solution using SQL Script. Below is the SQL I used. It is self explanatory. DECLARE @i int = 0 declare @suffix varchar (20) WHILE @i < 20 BEGIN SET @i = @i + 1 set @suffix = CAST(@i AS varchar (20)) /* do some work */ INSERT INTO [dbo].[Customer] ([FirstName] ,[LastName] ,[Phone] ,[Email]) VALUES ('F'+@suffix ,'L'+@suffix ,'Ph'+@suffix ,'Em'+@suffix ...
Comments