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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Error converting nvarchar to int
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bholmstrom
Yak Posting Veteran

USA
75 Posts

Posted - 03/14/2013 :  14:44:23  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6065 Posts

Posted - 03/14/2013 :  15:33:54  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000