How to put test data in a SQL Server table
You can use the following template to do this:
declare @i int =1
while @i < 200 begin
INSERT INTO [dbo].[tst_finances]
([fromID],[toID] ,[typeID],[statusID],[sum],[created],[projectID],[factPayed])
VALUES
((SELECT TOP 1 id FROM tst_customers ORDER BY NEWID())
,(SELECT TOP 1 id FROM tst_customers ORDER BY NEWID())
,(SELECT TOP 1 id FROM tst_finTypes ORDER BY NEWID())
,1
,rand()* 100000
,dateadd(day, - rand()*5000, getdate())
,(SELECT TOP 1 id FROM tst_projects ORDER BY NEWID())
,dateadd(day, - rand()*1000, getdate()) )
set @i = @i + 1
end
Consider the individual elements.
1. Paste N lines - make a while cycle and inside insert.
2. To fill in a value using a foreign key, select a random row from the parent table:
(SELECT TOP 1 id FROM tst_customers ORDER BY NEWID())
3. Getting a random number from 0 to N:
select rand()* 100000, cast(rand()* 100 as int)
4. Getting a random date (from 0 to N days ago)
dateadd(day, - rand()*1000, getdate())
5. Generating a random line:
select left(NEWID(),7)
In this simple way, you can quickly add any number of lines to the table.11
Additional
SQL. How to move to a new line in a string variable in SQL
SQL. Output HTML markup in crude form (as tags) in SQL
SQL. How to enter a date in a string in the desired format
SQL. How to use select from Storage
SQL. How to write a number in SQL in words
SQL. How to massively upload data to a Database table via CSV (Excel)
SQL-tool for creating personal accounts on the site

Falcon Space Platform
This is a reduction in the cost of ownership
at the expense of fewer people to support
This is a quick change
while using the program
This is a modern interface
full adaptation for mobile devices
MS SQL web applications. Affiliate program for developers and web studios
Platform documentation
