如何申报退货? [英] How to Declare a return?
问题描述
USE [OJTTEST]
GO
/ * *****对象:StoredProcedure [dbo]。[sp_getUserAccess]脚本日期:10/14 / 2013 15:20:17 ****** /
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
- ================= ============================
- 作者:匿名
- 创建日期:10/10/2013
- 描述:为用户访问获取sp
- == ===========================================
ALTER PROCEDURE [dbo]。[sp_getUserAccess]
( @ UserName varchar ( 25 ),
@密码 varchar ( 25 ))
< span class =code-keyword> AS
BEGIN
SET NOCOUNT ON ;
SELECT AccessWord
FROM [OJTTEST]。[dbo]。[UserAccess]
DECLARE @ return int
IF @ UserName = UserName AND @ Password = AccessWord
@ return = 1
ELSE
@ return = 0
END
我想创建一个存储过程,如果有访问权,它将返回1,否则返回0。但是有这个错误
Msg 102,Level 15,State 1,Procedure sp_getUserAccess,Line 16
'@return'附近的语法不正确。
我正在使用Microsoft SQL Server 2008 R2。这是我第一次创建SP。
嘿那里,
你错过了<$ c在@return =
之前$ c> SET 关键字,尝试:
设置 @ return = 1和
设置 @ return = 2
如果有帮助请告诉我。
注意:如果要从存储过程返回@return
,则需要将其用作OUTPUT
参数或在存储过程结束时选择
它。在这里,此链接显示了两种方法:
http://www.4guysfromrolla.com/文章/ 062905-1.aspx [ ^ ]
Azee ...
修改您的商店程序如下。以下代码将帮助您
创建 程序 [dbo]。[sp_getUserAccess]
(
@ UserName varchar ( 25 ),
@ Password varchar ( 25 )
)
AS
< span class =code-keyword> BEGIN
SET NOCOUNT ON 跨度>;
DECLARE @ return int
IF 存在(选择 UserName,AccessWord 来自 UserAccess 其中 UserName = @ UserName AND AccessWord = @ Password)
set @ return = 1
ELSE
set @ return = 0
END
USE [OJTTEST]
GO
/****** Object: StoredProcedure [dbo].[sp_getUserAccess] Script Date: 10/14/2013 15:20:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Anonymous
-- Create date: 10/10/2013
-- Description: get sp for user acess
-- =============================================
ALTER PROCEDURE [dbo].[sp_getUserAccess]
(@UserName varchar (25),
@Password varchar (25))
AS
BEGIN
SET NOCOUNT ON;
SELECT AccessWord
FROM [OJTTEST].[dbo].[UserAccess]
DECLARE @return int
IF @UserName=UserName AND @Password=AccessWord
@return = 1
ELSE
@return = 0
END
I want to make a stored procedure where it will return 1 if there is an access and 0 if not. But there was this error
"Msg 102, Level 15, State 1, Procedure sp_getUserAccess, Line 16
Incorrect syntax near '@return'."
I am using Microsoft SQL Server 2008 R2. It is my first time creating an SP.
Hey there,
You missedSET
keyword before@return =
, try:
Set @return = 1and
Set @return = 2
Let me know if it helps.
Note: If you want to return@return
from the stored procedure, you either need to use it as anOUTPUT
parameter orSelect
it at the end of the stored procedure. here, this link shows both methods:
http://www.4guysfromrolla.com/articles/062905-1.aspx[^]
Azee...
Modify Your Store Procedure as follow. The Following piece of code will help you
create PROCEDURE [dbo].[sp_getUserAccess] ( @UserName varchar (25), @Password varchar (25) ) AS BEGIN SET NOCOUNT ON; DECLARE @return int IF exists(select UserName,AccessWord from UserAccess where UserName=@UserName AND AccessWord =@Password) set @return = 1 ELSE set @return = 0 END
这篇关于如何申报退货?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!