Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if any one have sample example of insert and update store procedure in sql server 2008 then plz suggest to me....
Posted
Comments
nachiket03 25-May-12 2:38am    
i have little confusion about this
GO
/****** Object: StoredProcedure [dbo].[sp_getUserInfo] Script Date: 04/15/2012 12:27:00 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_getUserInfo]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_getUserInfo]

what is mean by this

Stored procedures are precompiled database queries that improve the security, efficiency and usability of database client/server applications.

They then compile the code on the database platform and make it available to aplication developers for use in other environments, such as web applications.

Please refer:
Sql Server - How to write a Stored procedure in Sql server[^]
Select, Insert, Update, Delete Using Stored Procedure[^]

Stored procedures in sql server 2008[^]
 
Share this answer
 
v2
Comments
nachiket03 25-May-12 2:34am    
thanks its realy helpful
Prasad_Kulkarni 25-May-12 2:46am    
You're welcome!
nachiket03 25-May-12 2:59am    
i have little confusion about this
GO
/****** Object: StoredProcedure [dbo].[sp_getUserInfo] Script Date: 04/15/2012 12:27:00 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_getUserInfo]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_getUserInfo]

what is mean by this
Wendelius 25-May-12 17:08pm    
Don't understand the downvote, countered
Prasad_Kulkarni 27-May-12 23:32pm    
Thanks Mika!
SQL
CREATE PROCEDURE Insert
-- Add the parameters for the stored procedure here
	@Id  nvarchar(150),
	@Name nvarchar(150),
	@Addr nvarchar(500)
AS
BEGIN

        -- Insert statements for procedure here
    Insert Into Sample(Id,Name,Address) Values(@Id,@Name,@Assr )

    END
GO
--For Update
CREATE PROCEDURE Upadte
-- Add the parameters for the stored procedure here
	@Id  nvarchar(150),
	 @Name nvarchar(150),
    @Addr nvarchar(500) 

 AS
BEGIN

        -- Insert statements for procedure here
    Update sample set Name=@Name,Address=@Addr where Id=@Id

    END
 
Share this answer
 
Comments
nachiket03 25-May-12 2:34am    
thanks its realy helpful
vangapally Naveen Kumar 25-May-12 3:07am    
You`re Welcome.........
Wendelius 25-May-12 17:09pm    
Downvote countered
member60 28-May-12 7:11am    
My 5!
C#
CREATE PROCEDURE [dbo].[SPDoctor]
(
@DoctorName varchar(50),
@HospitalName varchar(50),
@ContactNo varchar(50)
)
	 
AS
BEGIN
 insert into tblDrug_Doctor(DoctorName,HospitalName,ContactNo)values(@DoctorName,@HospitalName,@ContactNo)

END
 
Share this answer
 
v2
SQL
Create procedure product_List(@Class varchar(25))
as begin

select pm.part_name,pm.productID from product_master pm
where pm.product_classification like '%'+@Class

end
 
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