Click here to Skip to main content
14,977,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi team,
i have created a table as a cityMaster.i have column Id,city and state.
but i am confused ,
In a webform i have a textboxes like city and state.
if i select any cityname ,on basis of cityName i want the state.i wrote only select query
select * from citymaster with (nolock).
for this ,what will be the stored PRocedure.
how should i get it ??
kindly give me Idea..

Thanks
Harshal
Posted

your select query should be
SQL
select state from cityMaster where city='CITYNAME'
--or you can use id to retrieve state
select state from cityMaster where ID='ID'


Here are the basic tutorials for SQL[^]
   
v4
like this

SQL
create procedure spGetCityDetails
as
begin
select * from cityMaster
end


SQL
create procedue GetCitiesBasedOnState
(@state varchar(55))
as
begin
select * from cityMaster where [state] = @state
end



check this Sql Server - How to write a Stored procedure in Sql server[^]
   
v2

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