Click here to Skip to main content
13,289,626 members (61,643 online)
Rate this:
Please Sign up or sign in to vote.
Hi Frnds,
I have three tables with city,State,Country.In one Stored Procedure i need to insert,update ,select three table values.For that i need nested if Stored Procedure Flow.
for eg.: i am passing all my values from C# pages to stored procedure...
if i pass value as City.First i need to check whether that city name is already exist or not.after that if not exist i need to save,other wise i need to pass value to C# page as "Already Exist"...Same thing have to be do for State,Country
Posted 3-Dec-12 4:27am
ShailendraPatel 3-Dec-12 10:51am
how many columns in your table id and name or more what's the purpose of city,state,country if is cascading then use separate table for city,state and country


you have to store in this table your client info then also create three table and make cascading relationship between them and store id of city,state,country in user table
itsureshuk 4-Dec-12 0:06am
i have three tables(city state country)...I need one stored procedure ,if i am going to insert city details, i have to check, whether same city name is already exist, if not exist have to insert,otherwise if exist have to return a value 10 or that i can show message as already exist in User form

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Tou can try like this.

IF EXISTS(select * from city where Name = 'abc')
     return "already exists";
    IF(status = "update")
    { //write your update code here...}
    ELSE IF(status = "insert")
    {  //Write your insert query here...}
    { //select query...}


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 12 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100