Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update in SQL not updating 1

Status
Not open for further replies.

idanner

Programmer
Aug 30, 2004
17
US
Can anyone help with this update. If I set the values directly in the procedure it updates. If I use the arguments then it want update.

Code:
IF OBJECT_ID('dbo.spUpdateMyCustomersName')IS NOT NULL
	DROP PROC spUpdateMyCustomersName
	GO

	CREATE PROCEDURE spUpdateMyCustomersName ( 
	@arg_CompanyName VARCHAR,  
	@arg_CustomerID NCHAR )
	AS
	BEGIN
	  
	UPDATE MyCustomers SET  
	CompanyName=@arg_CompanyName 
	WHERE  
	CustomerID=@arg_CustomerID
	     
	END;

	GO
	EXEC spUpdateMyCustomersName   
        @arg_CustomerID='DUMON',
	@arg_CompanyName='Down Under Pub'

Thank you for any help.
 
WHen you set your datatypes for your input variables you need to specify how many characters you want them to contain or SQL will use the default which is 1 for varchar and I'm not sure what for nChar as I never use it. At any rate it didn;t find a match for the where clause since it didn't contain all the characters needed. Hence, no update was performed.

Questions about posting. See faq183-874
 
Thank you SQLSister. You were exactly right!
 
Whne you've made the same mistake yourself, it's a whole lot easier to see in someone else's code!

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top