Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,


Can anyone Know..

how to give where condition for insert query in stored procedure?
Posted
Comments
Menon Santosh 2-Mar-12 6:07am    
Where condition is applicable for update & Delete plz clarify your Question
Rajeev Jayaram 2-Mar-12 6:29am    
Why?

See my answer.
Chandrakantt 2-Mar-12 6:30am    
WHERE condition is not used in insert query. When you call insert query it means that you are inserting a new row in a table. WHERE condition is used in already present data. It is mostly used with UPDATE and DELETE command. If possible can you clarify more?
sathiyak 2-Mar-12 6:34am    
ya ok..but i have to show in register page when we enter email if it already there in database it should show already available..how to do...

You cann't. Because, you will not have this row yet for which you can do a where clause on it.

Use Update statement.
 
Share this answer
 
v2
Hi,

Use This

Table Name Employee

ID Name Age City
1 Aditya 22 Kanpur
2 Bhushan 24 Lucknow
3 Chaturvedi 23 Delhi

CREATE PROCEDURE GetDetails
AS
BEGIN
      select Name,Age,City from Employee WHERE ID=1
END
 
Share this answer
 
v2
hi there.....

try this ...

SQL
CREATE PROCEDURE spInsertProcedure
AS
BEGIN
     INSERT INTO tableName SELECT Column1 FROM tableName2 WHERE (Condition)..
END



hope this help u.
 
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