stored procedure sql server 2008 -
stored procedure sql server 2008 -
i working on project , using stored procedure. i'm getting error:
line: 939 error: sys.webforms.pagerequestmanagerservererrorexception: invalid object name 'it_assets'. transaction count after execute indicates mismatching number of begin , commit statements. previous count = 0, current count = 1.
please find below stored procedure code:
alter procedure [itassets_sp_it_assets] -- add together parameters stored procedure here (@mode varchar(12)='add', @id integer , @assetcode nvarchar(20)=null, @description nvarchar(70)=null, @site nvarchar(10)=null) begin if @mode='add' begin begin tran insert [it_assets] ([id] ,[assetcode] ,[description] ,[site]) values (@id, @assetcode, @description, @site ) if @@error <> 0 rollback tran else commit tran select @id end else begin begin tran update [it_assets] set assetcode = @assetcode, description = @description, site = @site id = @id if @@error <> 0 rollback tran else commit tran select @id end end
i didn't understand error , don't know problem? please help me in sloving problem?
from error invalid object name 'it_assets'
believe table/view 'it_assets' nowadays in diferent database stored procedure (assuming object exist , using right name).
then need quaify wih db name
update [db_name].[dbo].[it_assets] (assuming `dbo` owner)
try using database name @ top of procedure using use
statement like
use [db_name] go alter procedure [itassets_sp_it_assets] -- add together parameters stored procedure here (@mode varchar(12)='add', ...
also alter transaction handling using try .. catch
consruct below
begin tran begin seek insert [it_assets] ([id] ,[assetcode] ,[description] ,[site]) values (@id, @assetcode, @description, @site); commit tran; end seek begin grab rollback tran ; end grab
sql sql-server-2008 stored-procedures
Comments
Post a Comment