有 写存储过程的语法 介绍吗?本人菜的很

huzx 2003-08-24 05:34:39
存储过程到底是用到什么语法?
...全文
27 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
huzx 2003-08-26
  • 打赏
  • 举报
回复
呵呵,不好意思,自己看书弄懂了。
happy_0325 2003-08-25
  • 打赏
  • 举报
回复
CREATE PROC [ EDURE ] procedure_name [ ; number ]
[ { @parameter data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ]

[ WITH
{ RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]

[ FOR REPLICATION ]

AS sql_statement [ ...n ]
txlicenhe 2003-08-25
  • 打赏
  • 举报
回复
-- =============================================
-- Create procedure with CURSOR OUTPUT Parameters
-- =============================================
-- drop the store procedure if it already exists
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = N'<procedure_name, sysname, proc_test>'
AND type = 'P')
DROP PROCEDURE <procedure_name, sysname, proc_test>
GO


-- create the store procedure
CREATE PROCEDURE <procedure_name, sysname, proc_test>
<@proc_cursor_name, , @proc_test_cursor> CURSOR VARYING OUTPUT
AS
SET <@proc_cursor_name, , @proc_test_cursor> = CURSOR FOR
<select_statement, , select 1>
OPEN <@proc_cursor_name, , @proc_test_cursor>
GO


-- =============================================
-- example to execute the store procedure
-- =============================================
DECLARE <@variable_cursor_name, , @test_cursor_variable> CURSOR

EXEC <procedure_name, sysname, proc_test> <@proc_cursor_name, , @proc_test_cursor> = <@variable_cursor_name, , @test_cursor_variable> OUTPUT

WHILE (@@FETCH_STATUS = 0)
BEGIN
FETCH NEXT FROM <@variable_cursor_name, , @test_cursor_variable>
PRINT 'put user defined code here'
END

CLOSE <@variable_cursor_name, , @test_cursor_variable>

DEALLOCATE <@variable_cursor_name, , @test_cursor_variable>
GO

txlicenhe 2003-08-25
  • 打赏
  • 举报
回复
循环是不是这样写?
while condition
begin
......
end

是!!

yyy431706 2003-08-25
  • 打赏
  • 举报
回复
自己看吧
yyy431706 2003-08-25
  • 打赏
  • 举报
回复
sql server的联机丛书里有“存储过程”的例子
hxy2003 2003-08-25
  • 打赏
  • 举报
回复
UO


还是不懂
huzx 2003-08-24
  • 打赏
  • 举报
回复
怎么没得人理我呢?

我可是讲信用的哟
huzx 2003-08-24
  • 打赏
  • 举报
回复
等待……………………………………
huzx 2003-08-24
  • 打赏
  • 举报
回复
循环是不是这样写?
while condition
begin
......
end

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧