I made Wpf appliaction. I want to test it with 1000 values in grid. I want to check that whether my grid will load 1000 data records fastly or not. So how to write one query to insert more than 1000 records in my database table. can i use for loop.
Insert into db(@names,@email,@password) Values('abc','def','mypassword');
I am using Sql-Server 2012 and ADO.net Connectivity! I want to execute this query in database to generate 1000 rows
EDIT
What if i want to insert unique names?
If you just want to generate 1000 rows with random values: ;WITH x AS ( SELECT TOP (1000) n = REPLACE(LEFT(name,32),'_','') FROM sys.
First query USE CustomerDB; IF OBJECT_ID('Customer', 'U') IS NOT NULL DROP TABLE Customer; CREATE TABLE Customer ( CustomerID int PRIMARY KEY IDENTITY, CustomerName nvarchar(16), ...about 130 more columns... ); INSERT INTO Customer VALUES ('FirstCustomerName', ...), ... 1500 more rows...
You could use the table master. dbo. spt_values : set identity_insert #test1 off; insert into #test1 (test_id) select top (100) row_number() over (order by (select null)) from master.
INSERT-SELECT-UNION query to insert multiple records Thus, we can use INSERT-SELECT-UNION query to insert data into multiple rows of the table. The SQL UNION query helps to select all the data that has been enclosed by the SELECT query through the INSERT statement.
I create a student
table with three column id, student,age
. show you this example
declare @id int select @id = 1 while @id >=1 and @id <= 1000 begin insert into student values(@id, 'jack' + convert(varchar(5), @id), 12) select @id = @id + 1 end
this is the result about the example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With