Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have two table.
1.city->which contain id,cityname
2.city_course_details->which contain id ,city_id(which is reference to city table.)



how i write in stored procedure method so that,when i select city name it will also take information from city_course_details


Actually i want to know about foreign key, how i used through storeprocedure method..give any example
Posted
Updated 28-Sep-11 23:57pm
v2
Comments
P.Salini 29-Sep-11 5:54am    
clarify your question

Read this on how to create stored procedures Stored Procedures (Database Engine)[^] and this on how use a JOIN Join Fundamentals[^].

Good luck.
 
Share this answer
 
select cc.id,cc.city_id from city_course_details cc inner join city c
on cc.city_id=c.id
where c.cityname='your city name'


as far as i understood your question this is what you are looking for.
if this is not what you want then once again ask me some more clearly.
you can write this query in stored procedure.
 
Share this answer
 
v2
SQL
create proc Sel_City
@CityName nvarchar(50)
as
select CC.*, c.* from city_course_details cc inner join city c
on cc.city_id=c.id
where c.cityname=@CityName


You can change CC.* and C.* to only the required column name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900