Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 stored proc basic question

Author  Topic 

limericklad1974
Starting Member

39 Posts

Posted - 2009-01-07 : 16:39:56
Hi,
I have a database table called Database Settings. It has two columns (Name and Value)

Another programmer has written a stored proc which is called pr_dal_DatabaseSettings_SelectOne

It is written as follows:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[pr_dal_DatabaseSettings_SelectOne]
@Name varchar(50),
@ErrorCode int OUTPUT
AS
SET NOCOUNT ON
SELECT
[Name],
[Value]
FROM [dbo].[DatabaseSettings]
WHERE
[Name] = @Name
SELECT @ErrorCode=@@ERROR



We have started to get crashes on our application and I am wondering if this stored proc is causing the problem.

In the Database Settings table, there are entries which are 53 characters. The stored proc limits to 50, is this an issue???


Many thanks for any advice!

Damien.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-07 : 16:57:44
No. You are not reusing @name parameter.
Can you see in the log what causes crashes?


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

limericklad1974
Starting Member

39 Posts

Posted - 2009-01-07 : 18:27:46
quote:
Originally posted by Peso

No. You are not reusing @name parameter.
Can you see in the log what causes crashes?


E 12°55'05.63"
N 56°04'39.26"




Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 07/01/2009 14:38:07
Event time (UTC): 07/01/2009 14:38:07
Event ID: 26c6e1b1594b418295161ea316094fef
Event sequence: 1143
Event occurrence: 8
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/1/ROOT/CoachingData-1-128758090461375869
Trust level: Full
Application Virtual Path: /CoachingData
Application Path: C:\inetpub\wwwroot\CoachingData\
Machine name: MCFCORION

Process information:
Process ID: 2800
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:
Exception type: Exception
Exception message: DatabaseSettings::SelectOne::Error occurred.

Request information:
Request URL: http://mcfcorion/CoachingData/Default.aspx
Request path: /CoachingData/Default.aspx
User host address: 172.16.60.70
User: MCFC\Medicalroom
Is authenticated: True
Authentication Type: Negotiate
Thread account name: NT AUTHORITY\NETWORK SERVICE

Thread information:
Thread ID: 4
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at SportsAnalysis.DataAccessLayer.ObjectAccess.DatabaseSettings.SelectOne()
at bolton.BasePage.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Custom event details:
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-07 : 18:30:53
It'll truncate the data to 50 characters if you try to pass anything bigger. That's why data should be validated in the application before sending it to a parameter.

But this wouldn't cause anything to crash.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -