Jump to content
Araştır
  • Diğer seçenekler ...
Sonuçları bul ...
Sonuçları bul ...
aliemre123

"String or binary data would be truncated" hatası

Önerilen Mesajlar

Yeni karakter açmaya çalışırken gelen hata

[ ODBC Error - 30.9.2017 3:24:46 ] ] Source: {? = CALL CREATE_NEW_CHAR(?, 0, ?, 13, 202, 64020410, 4, 60, 70, 70, 50, 50)} Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]String or binary data would be truncated. Description: Failed to execute statement.



Create_New_char prosedürü

/*    ==Scripting Parameters==


Source Server Version : SQL Server 2016 (13.0.4001)
Source Database Engine Edition : Microsoft SQL Server Enterprise Edition
Source Database Engine Type : Standalone SQL Server

Target Server Version : SQL Server 2017
Target Database Engine Edition : Microsoft SQL Server Standard Edition
Target Database Engine Type : Standalone SQL Server
*/

USE [kn_online]
GO
/****** Object: StoredProcedure [dbo].[CREATE_NEW_CHAR] Script Date: 30.9.2017 03:26:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[CREATE_NEW_CHAR]
@strAccountID varchar(21),
@index tinyint,
@strCharID varchar(21),
@bRace tinyint,
@sClass smallint,
@nHair int,
@bFace tinyint,
@bStr tinyint,
@bSta tinyint,
@bDex tinyint,
@bIntel tinyint,
@bCha tinyint
AS

DECLARE @bNation tinyint
DECLARE @bCharCount tinyint
DECLARE @bCount tinyint

SELECT @bNation = bNation, @bCharCount = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @strAccountID

IF (@bNation = 1 AND @bRace > 10)
RETURN 2
ELSE IF (@bNation = 2 AND @bRace RETURN 2
ELSE IF (@bNation 1 AND @bNation 2)
RETURN 2

SELECT @bCount = COUNT(strUserID) FROM USERDATA WHERE strUserID = @strCharID

IF (@bCount > 0)
RETURN 3

BEGIN TRAN
IF (@index = 0)
UPDATE ACCOUNT_CHAR SET strCharID1 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID
ELSE IF (@index = 1)
UPDATE ACCOUNT_CHAR SET strCharID2 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID
ELSE IF (@index = 2)
UPDATE ACCOUNT_CHAR SET strCharID3 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID
ELSE IF (@index = 3)
UPDATE ACCOUNT_CHAR SET strCharID4 = @strCharID, bCharNum += 1 WHERE strAccountID = @strAccountID

IF (@@ERROR 0 OR @@ROWCOUNT = 0)
BEGIN
ROLLBACK TRAN
RETURN 4
END

INSERT INTO USERDATA (strUserID, Nation, Race, Class, HairRGB, Face, Strong, Sta, Dex, Intel, Cha)
VALUES (@strCharID, @bNation, @bRace, @sClass, @nHair, @bFace, @bStr, @bSta, @bDex, @bIntel, @bCha)


update USERDATA SET zone=21 where zone = 21
DECLARE @bFree tinyint
SET @bFree = 0
EXEC ITEM_VER @StrCharID
IF (@@ERROR 0)
BEGIN
ROLLBACK TRAN
RETURN 4
END
COMMIT TRAN

RETURN 0


item_ver prosedürü

/*    ==Scripting Parameters==


Source Server Version : SQL Server 2016 (13.0.4001)
Source Database Engine Edition : Microsoft SQL Server Enterprise Edition
Source Database Engine Type : Standalone SQL Server

Target Server Version : SQL Server 2017
Target Database Engine Edition : Microsoft SQL Server Standard Edition
Target Database Engine Type : Standalone SQL Server
*/

USE [kn_online]
GO
/****** Object: StoredProcedure [dbo].[ITEM_VER] Script Date: 30.9.2017 03:27:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[ITEM_VER]
@strUserId varchar(21)
AS
BEGIN

DECLARE @Class smallint
DECLARE @MASTER smallint

SELECT @Class = Cast(SubString(Cast(Class as varchar(3)), 2, 2) as smallint) FROM USERDATA WHERE strUserId = @strUserId

IF @Class = 1 OR @Class = 5 OR @Class = 6
SET @Class = 1

IF @Class = 2 OR @Class = 7 OR @Class = 8
SET @Class = 2

IF @Class = 3 OR @Class = 9 OR @Class = 10
SET @Class = 3

IF @Class =4 OR @Class = 11 OR @Class = 12
SET @Class = 4

UPDATE USERDATA SET strItem = (SELECT strItem FROM BEGINNER_ITEM WHERE iClass = @Class), Gold = (SELECT Gold FROM BEGINNER_ITEM WHERE iClass = @Class) WHERE strUserId = @strUserId

END



son olarak beginner_item tablosu

jQ2ljL.png

hata nerden kaynaklı acaba

İletiyi paylaş


Link to post
Sitelerde Paylaş
"String or binary data would be truncated" hatası, prosedüre parametre olarak verdiğin bir varchar veya varbinary değerinin, kaydedileceği sütunun tanımlı değerinden daha uzun oldugunu belirtir. Örneğin strUserId 21 karakter uzunluğunda tanımlı, prosedüre 22 karakter uzunluğunda kullanıcı adı verirsen bu hata ile karşılaşırsın.

BEGINNER_ITEM'deki strItem uzunluğu le USERDATA'daki strItem uzunluğu uyuşmuyor olabilir. 'var'binary-char tipi sütunların uzunluklarını karşılaştır.

İletiyi paylaş


Link to post
Sitelerde Paylaş

Dipnot olarak, bir dahaki sefere konu açarken konu başlığı yaşadığın sorunu özetlerse, forumdaki arkadaşların sana yardımcı olması daha kolay olur. Bu konunun başlığını bu seferlik ben düzenliyorum.

İletiyi paylaş


Link to post
Sitelerde Paylaş
Misafir
Bu konu kapalıdır ama konuya cevap yazmaya yetkiniz var görünüyor.

×
×
  • Yeni Oluştur...