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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Error converting nvarchar to int

Author  Topic 

bholmstrom
Yak Posting Veteran

76 Posts

Posted - 2013-03-14 : 14:44:23
I have a procedure:

CREATE PROCEDURE [UPDATE_STATUS]
(
@RecID int

)
AS
Update ncos_Plain SET NC_Status_Updated = getdate()
WHERE NC_UniqueID = @RecID
GO

--------------------------------------------

This procedure is getting called by a trigger on update:

CREATE TRIGGER [update_status_date] ON [dbo].[NCOS_PLAIN]
FOR UPDATE
AS
EXEC UPDATE_STATUS NC_UNIQUEID

The system throws an error:

Error converting data type nvarchar to int.

The field nc_uniqueid is a integer.

Beyond that I would really only like to update the field when one fields is altered.

Any thoughts ideas......Thanks


Bryan Holmstrom

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-03-14 : 15:33:54
EXEC UPDATE_STATUS NC_UNIQUEID
That parameter value needs to either be an integer or a integer typed variable. that is why you're getting the error. but in any case you need to be able to deal with multiple values being updated in a single statement.

use this as your trigger body instead:

Update p SET
NC_Status_Updated = getdate()
from inserted i
join ncos_Plain p on p.NC_UniqueID = i.NC_UniqueID



Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -