In this article I am going to explain how to insert multiple
tables data into one table in sql server.
In previous article I have explained how to add Facebook like,share and comment box in asp.net website, how to upload and read text file inasp.net and how to upload and read word document in asp.net.
Implementations:
I have created 2 tables Country and state, insert some dummy
records into it. I want to insert country and state name into another table (countrystate).
Tb_Country
Id
|
int
|
CountryName
|
varchar(100)
|
Tb_State
Id
|
int
|
StateName
|
varchar(100)
|
CountryId_Fk
|
int
|
CountryState
CSId
|
int
|
Country
|
varchar(200)
|
Statename
|
varchar(200)
|
Recdate
|
date
|
Get the date from both table using join and insert into table.
Insert into CountryState(Country,Statename)
SELECT dbo.Tb_State.StateName, dbo.Tb_Country.CountryName
FROM dbo.Tb_Country
INNER JOIN
dbo.Tb_State ON dbo.Tb_Country.Id = dbo.Tb_State.CountryId_Fk
No comments:
Post a Comment