在SQL Server 2005中创建存储过程 [英] Create a stored procedure in SQL Server 2005
本文介绍了在SQL Server 2005中创建存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个存储过程以将数据插入到SQL Server 2005的表中。
提前感谢!
I want to create one stored procedure to insert data into a table of SQL Server 2005.
Thanks in advance!
推荐答案
语法如下:
The syntax is as follows:
CREATE PROCEDURE SomeStoredProcedure
@SomeParam int,
@AnotherParam int
AS
BEGIN
INSERT INTO SomeTable(SomeColumn, AnotherColumn) VALUES(@SomeParam, @AnotherParam)
END
假设你的桌子名字是T1,wh ich有两列名称和名称。
程序名称为InsertIntoT1。
Suppose your table name is T1,which has two columns Name and Designation.
Procedure Name is InsertIntoT1.
Create proc InsertIntoT1(@Name varchar(50),@Designation varchar(50))
as
begin
insert into T1(Name,Designation)values(@Name,@Designation);
end
/ *如何调用存储过程* /
/*How to call the stored procedure*/
exec InsertIntoT1 'Sajid Ahmed Shahsroha','Team Lead/Sr.Software Engineer'
示例:
Example:
create procedure Proc_Name
@Column1Value DataType,
@Column2Value DataType
as
begin
insert into TableName
(
Column1,
Column2
)
values
(
@Column1Value,
@Column2Value
)
end
使用以下语句执行存储过程:
Execute the Stored Procedure By Using the following Statement:
exec Proc_Name 'TestValue1','TestValue2'
谢谢,
Raja.S
Thanks,
Raja.S
这篇关于在SQL Server 2005中创建存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文