sql server - How can I make a stored procedure commit immediately? -
edit questions no longer valid issue else. please see explanation below in answer.
i'm not sure of etiquette i'l leave question in its' current state
i have stored procedure writes data table.
i'm using microsoft practices enterprise library making stored procedure call. invoke stored procedure using call executenonquery.
after executenonquery returns invoke 3rd party library. calls me on separate thread in 100 ms.
i invoke stored procedure pull data had written. in 99% of cases data returned. once in while returns no rows( ie can't find data). if put conditional break point detect condition in debugger , manually rerun stored procedure returns data.
this makes me believe writing stored procedure working not committing when called.
i'm novice when comes sql, entirely possible i'm doing wrong. have thought writing stored procedure block until contents committed db.
writing stored procedure
alter procedure [dbo].[spwrite] @guid varchar(50), @data varchar(50) begin -- set nocount on added prevent result sets -- interfering select statements. set nocount on; -- see if guid has been added table declare @foundguid varchar(50); select @foundguid = [guid] [dbo].[details] [guid] = @guid; if @foundguid null -- first time we've seen guid insert [dbo].[details] ( [guid], data ) values (@guid, @data) else -- updaeting or verifying order update [dbo].[details] set data =@data [guid] = @guid end set ansi_nulls on go set quoted_identifier on go
reading stored procedure
alter procedure [dbo].[spread] @guid varchar(50) begin -- set nocount on added prevent result sets -- interfering select statements. set nocount on; select * [dbo].[details] [guid] = @guid; end
to block other transactions , manually commit, maybe adding
begin transaction --place --transactions wish here --if okay commit transaction --or --rollback transaction if went wrong
could you?