Data base :sql server 2008
Step 1:I have a table called "excel" in sql database having columns like cname,firstname,Lastname,etc. I need to fetch all the data from "excel" table using fetch cursor.
Step 2: Once i fetch the data then i need to compare cname with comp_name column with Company table.
if company_name Exist fetch the id for that company else insert the company name as new data
Step 3:once company name exist ,once i fetched the id then with that id i have to compare firstname in person table. if person exists get the id else insert firstname in to person table as new data.
Step 4:if company name exists ,firstname exists get the id and check if lastname exists or not
if exists get id else insert lastname.
Objective is to write stored procedure ,Firstly i have to check the comp_name if exists get id ,with that id i have to check the firstname in person table if exists again get id and check for lname.