Insert Data Dynamically in SQL Server
In this tutorial see about SQL Server insert Data Dynamically.
create a table tbl_name
create table tbl_name(id int identity primary key,name nvarchar(20),age int)
declare @ID as int
set @ID=1
while(@ID<=5)
begin
insert into tbl_name values('name'+ CAST(@ID as nvarchar(20)),@ID)
print @ID
set @ID=@ID+1
end
Output:
create a table tbl_name
create table tbl_name(id int identity primary key,name nvarchar(20),age int)
declare @ID as int
set @ID=1
while(@ID<=5)
begin
insert into tbl_name values('name'+ CAST(@ID as nvarchar(20)),@ID)
print @ID
set @ID=@ID+1
end
Output:
Comments
Post a Comment
Thank You for your Comment