USE pubs IF EXISTS (SELECT name FROM sysobjects WHERE name = 'au_info_all' AND type = 'P') DROP PROCEDURE au_info_all GO CREATE PROCEDURE au_info_all AS SELECT au_lname, au_fname, title, pub_name FROM authors a INNER JOIN titleauthor ta ON a.au_id = ta.au_id INNER JOIN titles t ON t.title_id = ta.title_id INNER JOIN publishers p ON t.pub_id = p.pub_id GOau_info_all 存储过程可以通过以下方法执行:EXECUTE au_info_all -- Or EXEC au_info_all
AS
BEGIN
SELECT * FROM 表
END
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'au_info_all' AND type = 'P')
DROP PROCEDURE au_info_all
GO
CREATE PROCEDURE au_info_all
AS
SELECT au_lname, au_fname, title, pub_name
FROM authors a INNER JOIN titleauthor ta
ON a.au_id = ta.au_id INNER JOIN titles t
ON t.title_id = ta.title_id INNER JOIN publishers p
ON t.pub_id = p.pub_id
GOau_info_all 存储过程可以通过以下方法执行:EXECUTE au_info_all
-- Or
EXEC au_info_all
在程序中通过 SqlCommand提供的参数,接收返回的数据集赋给一个dataset. 有没有现成的代码,发出来给我参考参考,谢谢`1
程序代码不要,只要 相应的存储过程代码就行了。
存储过程中这样不知道行不行
,没测试
CREATE PROC #p_test
AS
BEGIN
SELECT * FROM 表;
SELECT * FROM 表名;
END
存储过程如下:
create proc aa_a
as
begin
select * from dbo.Customers;
select * from dbo.Employees;
end在C#中调用如下:
private void Form1_Load(object sender, System.EventArgs e)
{
sqlConnection1.Open();
sda=new SqlDataAdapter("exec aa_a",sqlConnection1);
sda.Fill(ds); MessageBox.Show(ds.Tables.Count.ToString());
}