Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi all,

I have a bit of a problem that I'm hoping you guys can assist with it. I have a server running SQL 2012 at a client and am running a restored set of their data (last restored around June). Neither has any SQL Cumulative updates installed.

I have a number of Stored Procedures that expects quite a few parameters, but only some of these are mandatory. I have been running this fine until recently (although exactly how recently I don't know, but it did work before). But now every single parameter is required. What could have changed? Where can I start looking.

So just to sum up: Before I was able to pass blank parameters to the SP, but now I can't. i can assign default values, but I want to know what actually happened.

Edit: Here is the SProc and the code calling it:
USE [MyDB]
GO
/****** Object: StoredProcedure [dbo].[sp_CCNEW] Script Date: 10/11/2014 7:56:56 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[sp_CCNEW]

@ipkCID int,
@sLastName VARCHAR (40),
@sFirstName VARCHAR (40),
@sInitials VARCHAR (10),
@sSalutation VARCHAR (20),
@sHobbies VARCHAR (100),
@sNotes text

AS

DECLARE @ifkCID INT

SET @ifkCID = (SELECT ifkCsID FROM tblCC WHERE ipkCCID = @ipkCID)

Update tblCC SET

sLastName = @sLastName,
sFirstName = @sFirstName,
sInitials = @sInitials ,
sSalutation = @sSalutation ,
sHobbies = @sHobbies ,
sNotes = @sNotes
WHERE ipkCCID = @ipkCID


The code calling it:
VB
conDB.Execute ("EXEC sp_CCNew " & _
             "@ipkCID=" & txtContactID & ", " & _
             "@sLastName='" & SQLReplace(txtLastName.Text) & "', " & _
             "@sFirstName='" & SQLReplace(txtFirstName.Text) & "', " & _
             "@sInitials='" & SQLReplace(txtInitials.Text) & "', " & _
             "@sSalutation='" & SQLReplace(txtSalutation.Text) & "', " & _
             "@sHobbies='" & SQLReplace(txtHobbies.Text) & "', " & _
             "@sNotes='" & SQLReplace(txtContactNotes.Text)



SQLReplace is a function that replaces blanks with ''.

I originally thought it might be the set quote identifiers, but I did the same at the client (changed it to OFF) with no change on their side...

PS:I have just rechecked the client's side and mine and it works. Could the Quote Identifier be responsible?
Posted
Updated 9-Nov-14 19:28pm
v2
Comments
Thanks7872 10-Nov-14 0:55am    
You should not expect that the explanation above can help us find out cause of an issue. You would have posted a stored procedure and the relevant code block calling it. Use improve question at bottom of the question and post relevant info.
Thava Rajan 10-Nov-14 1:56am    
seems you are missing the final part of the .net code

1 solution

What turns a parameter in SQL stored procedure non-required is setting a default value for it - http://technet.microsoft.com/en-us/library/ms189330(v=sql.105).aspx[^]
In your SP none of the parameters has default value, so all of them required...
 
Share this answer
 
Comments
craigba 10-Nov-14 1:57am    
That's my point: It wasn't requiring the parameters before - and now it is requiring them. Adding the default values will work, but I would like to know why it's suddenly behaving this way...
Kornfeld Eliyahu Peter 10-Nov-14 2:00am    
As I can't see your previous code/SQL I can't tell...
The behavior you encounter now IS the default behavior of SQL...
craigba 10-Nov-14 2:02am    
The weird thing is no code has changed here... The same Sproc is being called by the same piece of code...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900