The Queries in this page solved at the library database. It is a sample database generated by randomly records. You can download it from the link. You will see more than 500 examples in the future. You can filter from the search panel above by selecting sql statements. I hope you will like it
Solution 1)
Insert into students(name,surname)
Select name,surname from authors
ETİKETLER
Select - Insert -Solution 1)
Insert into authors(name,surname)
select name,surname from students
where sinif='9A' and gender='M'
Solution 2)
Insert into authors
select name,surname from students
where sinif='9A' and gender='M'
ETİKETLER
Select - Insert - Where -Solution 1)
Insert into authors(name,surname)
Select top 5 name,surname from students order by newid()
ETİKETLER
Select - Insert - Top - Order By -Solution 1)
Insert into students(name,surname,sinif)
Select name,surname,'12M' from authors where name like '%a%'
ETİKETLER
Select - Insert - Where -Solution 1)
Create procedure randomGenerate(@unit int,@min int,@max int)
as
Begin
Declare @numbers table(number int)
Declare @i int = 0
Declare @number int
while (@i<@unit)
Begin
Set @number = floor(rand()*(@max-@min+1))+@min
if(not exists(Select * from @numbers where number = @number))
begin
insert into @numbers values(@number)
Set @i = @i + 1
end
end
Select * from @numbers order by 1
End
--To Execute Stored Procedure
Execute randomGenerate 5,20,30
ETİKETLER
Select - Insert - Procedure - Declare -