首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

关于一个存储过程,初学者!100分随拿

2012-01-28 
关于一个存储过程,菜鸟请求帮助!100分随拿CREATEPROCEDURENEW_CHAR@accountvarchar(20),@indexsmallint,@i

关于一个存储过程,菜鸟请求帮助!100分随拿



CREATE     PROCEDURE   NEW_CHAR
               
@accountvarchar(20),
@indexsmallint,
@idvarchar(20)           ,
@STRsmallint,
@CONsmallint,
@DEXsmallint,
@VOLsmallint,
@WISsmallint,
@Skinint,
@Hairint,
@Gendersmallint,
@Classtinyint,
@Facevarbinary(10),
@Skillvarbinary(100),
@Itemvarbinary(1500),
@Psivarbinary(100),
@Abnormalvarbinary(4),  
@QuickItemvarbinary(10),
@HPsmallint,
@PPsmallint,
@SPsmallint
AS
DECLARE
@BankIDvarchar(20),
@charMaxNumsmallint,
@AccountBankIDvarchar(20)
SET@charMaxNum   =   0   ,@id=@id+ '[A] '

BEGIN   TRAN
INSERT   INTO   GAMEUSER  
(
strUserID,   sSTR,   sCON,   sDEX,   sVOL,   sWIS,   iSkin,   iHair,   sGender,   strFace,
sMaxHP,   sHP,   sMaxPP,   sPP,   sMaxSP,   sSP,   byClass,   strSkill,   strItem,   strPsi,  
  strAbnormal,   strQuickItem,   sBasicSTR,   sBasicCON,   sBasicDEX,   sBasicVOL,   sBasicWIS
)
VALUES    
(
                                                                             
@id,--   strUserID
@STR,--   sSTR
@CON,--   sCON
@DEX,--   sDEX
@VOL,--   sVOL
@WIS,--   sWIS
@Skin,--   iSkin
@Hair,--   iHair
@Gender,--   sGender
@Face,--   strFace
@HP,--   sMaxHP
@HP,--   sHP   =   sMaxHP  
@PP,--   sMaxPP
@PP,--   sPP   =   sMaxPP
@SP,--   sMaxSP
@SP,--   sSP   =   sMaxSP
@Class,--   byClass
@Skill,--   strSkill
@Item,--   strItem
@Psi,--   strPsi
@Abnormal,--   strAbnormal
@QuickItem,--   strQuickItem
@STR,--   sSTR       ???   ????.
@CON,--   sCON
@DEX,--   sDEX
@VOL,--   sVOL
@WIS--   sWIS
)

IF   (@index   =   0)
BEGIN
UPDATE   CHARS   SET   strChar01   =   @id,   sCharNum   =   sCharNum   +   1   WHERE   strAccount   =   @account
END
IF   (@index   =   1)
BEGIN
UPDATE   CHARS   SET   strChar02   =   @id,   sCharNum   =   sCharNum   +   1   WHERE   strAccount   =   @account
END
IF   (@index   =   2)
BEGIN
UPDATE   CHARS   SET   strChar03   =   @id,   sCharNum   =   sCharNum   +   1   WHERE   strAccount   =   @account
END
SELECT   @charMaxNum   =   sCharNum   FROM   CHARS   WHERE   strAccount   =   @account
INSERT   INTO     USER_BANK(strAccount)     VALUES(   @id   )

select   @AccountBankID   =   strAccount   from   account_bank   where   strAccount   =   @account


if   @@rowcount   =   0
begin
insert   into   account_bank(strAccount)   values   (@account)
end

IF   (@@ERROR   <>   0     OR     @charMaxNum   > =     4)
BEGIN  
ROLLBACK   TRAN  
RETURN   255
END
ELSE
BEGIN
COMMIT   TRAN
RETURN   0
END


GO
-------------------------------

以上是一个   存储过程,其中变量@id   我想给他@id+ '[A] '   但执行时会不正常.请大虾帮忙看下   是不是我需要另外再定义一个变量?   请教!

[解决办法]
SET@charMaxNum = 0, @id=@id+ '[A] '

---->

SET@charMaxNum = 0
set @id=@id+ '[A] '
[解决办法]
SET@charMaxNum = 0 ,@id=@id+ '[A] '
----->

SET @charMaxNum = 0
SET @id=@id+ '[A] '

热点排行
Bad Request.