How to add dummy Data in a sql server table

  By Junaid A   Posted on April-26-2018   949

.Net

How to add dummy Data in a sql server table

 

1) Write Query that will insert data in a table

 

INSERT [dbo].[Ads] ( [ReferenceNumber], [AdName], [AdDescription], [City_Id], [Model_Id], [Year], [TransmittionType], [Color], [FuelType], [RegionalSpecs], [MortgageDetails], [AskingPrice], [MileageKM], [IsFeatured], [Account_Id], [AdStatus_Id], [TicketsQuantity], [RemainingTicketsQuantity], [CreatedDate], [ExpiryDate], [TicketPrice], [AboutWarrenty], [BodyType], [ServiceHistory], [DeleteReason], [MulkiyaFrontURL], [MulkiyaBackURL], [OwnershipDocumentURL], [OwnershipType], [IsUserFavouirte]) VALUES (N'WD-1492555', N'Audi  for sale', N'Description', 2, 432, 2010, N'Automatic Transmission', N'Silver', N'Diesel', N'Japanese Specs', NULL, CAST(10000.00 AS Decimal(18, 2)), 123, 1, 133, 1, 600, 598, CAST(0x0000A8CB01187186 AS DateTime), CAST(0x0000A8D2013A36E0 AS DateTime), CAST(25.00 AS Decimal(18, 2)), N'Yes', N'Sports Car', 1, NULL, NULL, NULL, N'6366006006380526061.pdf', N'otherOwnershipDoc', NULL)

 

2) Create  a while loop that will  repate that query

 

DECLARE @i int = 0

 

WHILE @i < 20

BEGIN

    SET @i = @i + 1

    /* do some work */

END

 

 

3) merg result will be  below

 

 

 

 

DECLARE @i int = 0

 

WHILE @i < 20

BEGIN

    SET @i = @i + 1

    /* do some work */

 

INSERT [dbo].[Ads] ( [ReferenceNumber], [AdName], [AdDescription], [City_Id], [Model_Id], [Year], [TransmittionType], [Color], [FuelType], [RegionalSpecs], [MortgageDetails], [AskingPrice], [MileageKM], [IsFeatured], [Account_Id], [AdStatus_Id], [TicketsQuantity], [RemainingTicketsQuantity], [CreatedDate], [ExpiryDate], [TicketPrice], [AboutWarrenty], [BodyType], [ServiceHistory], [DeleteReason], [MulkiyaFrontURL], [MulkiyaBackURL], [OwnershipDocumentURL], [OwnershipType], [IsUserFavouirte]) VALUES (N'WD-1492555', N'Audi  for sale', N'Description', 2, 432, 2010, N'Automatic Transmission', N'Silver', N'Diesel', N'Japanese Specs', NULL, CAST(10000.00 AS Decimal(18, 2)), 123, 1, 133, 1, 600, 598, CAST(0x0000A8CB01187186 AS DateTime), CAST(0x0000A8D2013A36E0 AS DateTime), CAST(25.00 AS Decimal(18, 2)), N'Yes', N'Sports Car', 1, NULL, NULL, NULL, N'6366006006380526061.pdf', N'otherOwnershipDoc', NULL)

 

/**/

END

 

 

By  asifjans    26-Apr-2018 Views  949



You may also read following recent Post

Item Image
What are 3 C
 219
Item Image
what is .net
 451