Question : MS SQL Stored Procedure miscounting number of characters

Help, I'm experiencing a character count problem with an MS SQL Insert Stored Procedure...

The stored procedure (call) in the code section below forms part of an ASP page that processes data sent using HTTP POST by a third party application -

The Stored Procedure itself reads like -

"USE [JobBoardRegion]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[JobboardBBinsert]
 @BBSITEID int,
 @BBJBEID INT,
 @BBJBCLID INT,
 @jobtitle nvarchar(64),
 @description nvarchar(max),
 @payrate nvarchar(250),
 @BBLOCATION NVARCHAR(50),
 @category nvarchar(50),
 @employmenttype nvarchar(50),
 @reference nvarchar(250),
 @startdate nvarchar(50),
 @conkermail nvarchar(255),
 @BBCLIENTTOKENACCOUNT NVARCHAR(1)
AS

INSERT INTO dbo.JBAdvert (
JBASiteID,
JBAEmployeeID,
JBAClientID,
JBATitle,
JBADescription,
JBAPayRate,
JBALocation,
JBACategory,
JBAEmplymentType,
JBAReference,
JBAStartDate,
JBAPostFor,
JBAConkersEmail,
JBAFeaturedJob,
JBAOverWrite
)
Values (
@BBSITEID,
@BBJBEID,
@BBJBCLID,
@jobtitle,
@description,
@payrate,
@BBLOCATION,
@category,
@employmenttype,
@reference,
@startdate,
'28',
@conkermail,
@BBCLIENTTOKENACCOUNT,
'N')



GO"

In some instances this is working fine, however occasionally, we get the following error -

"<p>Microsoft OLE DB Provider for SQL Server</font> <font face="Arial" size=2>error '80040e57'</font>
<p>
<font face="Arial" size=2>String or binary data would be truncated.</font>
<p>
<font face="Arial" size=2>/multipost/newpost.asp</font><font face="Arial" size=2>, line 496</font>"

where line 496 of the full ASP page is -

"CMDInsertAD.Execute()"

I have checked everything else, and despite everything meeting the criteria set, and the description being less than 6000 characters, for some reason when the stored procedure is being run, it calculates the description field as being more than 6000 characters.

I'm really at a loss as to whatis causing this glitch, or how to resolve, so would appreciate any assistance on offer please...

Thank you

database is ms sql 2008 - :-)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
<%

Dim CMDInsertAD__BBSITEID
CMDInsertAD__BBSITEID = "0"
if(Session("BBSITEID") <> "") then CMDInsertAD__BBSITEID = Session("BBSITEID")

Dim CMDInsertAD__BBJBEID
CMDInsertAD__BBJBEID = "0"
if(Session("BBJBEID") <> "") then CMDInsertAD__BBJBEID = Session("BBJBEID")

Dim CMDInsertAD__BBJBCLID
CMDInsertAD__BBJBCLID = "0"
if(Session("BBJBCLID") <> "") then CMDInsertAD__BBJBCLID = Session("BBJBCLID")

Dim CMDInsertAD__jobtitle
CMDInsertAD__jobtitle = "0"
if(Request.Form("jobtitle") <> "") then CMDInsertAD__jobtitle = Server.HTMLEncode(Request.Form("jobtitle"))

Dim CMDInsertAD__description
CMDInsertAD__description = "0"
if(Request.Form("description") <> "") then CMDInsertAD__description = Server.HTMLEncode(Request.Form("description"))

Dim CMDInsertAD__payrate
CMDInsertAD__payrate = "0"
if(Request.Form("payrate") <> "") then CMDInsertAD__payrate = Server.HTMLEncode(Request.Form("payrate"))

Dim CMDInsertAD__BBLOCATION
CMDInsertAD__BBLOCATION = "0"
if(Session("BBLOCATION") <> "") then CMDInsertAD__BBLOCATION = Session("BBLOCATION")

Dim CMDInsertAD__category
CMDInsertAD__category = "0"
if(Request.Form("category") <> "") then CMDInsertAD__category = Request.Form("category")

Dim CMDInsertAD__employmenttype
CMDInsertAD__employmenttype = "0"
if(Request.Form("employmenttype") <> "") then CMDInsertAD__employmenttype = Request.Form("employmenttype")

Dim CMDInsertAD__reference
CMDInsertAD__reference = "0"
if(Request.Form("reference") <> "") then CMDInsertAD__reference = Server.HTMLEncode(Request.Form("reference"))

Dim CMDInsertAD__startdate
CMDInsertAD__startdate = "0"
if(Request.Form("startdate") <> "") then CMDInsertAD__startdate = Server.HTMLEncode(Request.Form("startdate"))

Dim CMDInsertAD__conkermail
CMDInsertAD__conkermail = "0"
if(Request.Form("altemail") <> "") then CMDInsertAD__conkermail = Request.Form("altemail")

Dim CMDInsertAD__BBCLIENTTOKENACCOUNT
CMDInsertAD__BBCLIENTTOKENACCOUNT = "0"
if(Session("BBCLIENTTOKENACCOUNT") <> "") then CMDInsertAD__BBCLIENTTOKENACCOUNT = Session("BBCLIENTTOKENACCOUNT")

%>
<%

set CMDInsertAD = Server.CreateObject("ADODB.Command")
CMDInsertAD.ActiveConnection = MM_recruta2_STRING
CMDInsertAD.CommandText = "dbo.JobboardBBinsert"
CMDInsertAD.CommandType = 4
CMDInsertAD.CommandTimeout = 0
CMDInsertAD.Prepared = true
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@RETURN_VALUE", 3, 4)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@BBSITEID", 3, 1,8,CMDInsertAD__BBSITEID)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@BBJBEID", 3, 1,8,CMDInsertAD__BBJBEID)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@BBJBCLID", 3, 1,8,CMDInsertAD__BBJBCLID)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@jobtitle", 200, 1,64,CMDInsertAD__jobtitle)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@description", 200, 1,6000,CMDInsertAD__description)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@payrate", 200, 1,50,CMDInsertAD__payrate)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@BBLOCATION", 200, 1,50,CMDInsertAD__BBLOCATION)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@category", 200, 1,50,CMDInsertAD__category)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@employmenttype", 200, 1,50,CMDInsertAD__employmenttype)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@reference", 200, 1,50,CMDInsertAD__reference)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@startdate", 200, 1,50,CMDInsertAD__startdate)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@conkermail", 200, 1,255,CMDInsertAD__conkermail)
CMDInsertAD.Parameters.Append CMDInsertAD.CreateParameter("@BBCLIENTTOKENACCOUNT", 200, 1,1,CMDInsertAD__BBCLIENTTOKENACCOUNT)
CMDInsertAD.Execute()

%>

Answer : MS SQL Stored Procedure miscounting number of characters

Unless otherwise you set the MAX Server Memory of SQL Server, it would try to utilize as much memory available in the server and hence utilizing 2 GB is not a big deal as SQL server loves more memory for optimizing things even though it doesn't have much activity as mentioned..

>> Is there any way to find out what SQL server is doing ? I'm of a mind to just stop the services for it as we don't use any of the reporting/monitoring functionality but I'd prefer to find the root cause if at all possible

Just execute this script in query window:

select * from sys.sysprocesses

which would list the activities happening in the server.

And regarding disk activity, if you have heavily fragmented databases, then this should happen.
Rebuild all indexes in your database to fix this one..
Random Solutions  
 
programming4us programming4us