Insert SQL does not work in stored procedure.

From: Mike G (MikeG_at_discussions.microsoft.com)
Date: 01/17/05


Date: Mon, 17 Jan 2005 14:29:03 -0800

On one of our development servers I've run into a problem with Insert
command. The stored procedure works on other servers and used to work on
this server. I've reduced the actual code to a trivial set that still
exhibits the behavior.

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

ALTER procedure sp_wr_xmldoc3_ex @doc_passed text -- uniqueidentifier
 as
 begin tran

------------------------------------------------------------------------------------
-- DEBUG!
insert into Logical_Tag_Data
  ( uopLogicalTagId, uopTimeStart, uopTimeEnd, uopFltValue, uopStrValue )
values
  (
    '3AF75E96-F354-49E2-97AC-DC9779EE7B5F',
    '2005-01-11 00:00:00.000',
    '2005-01-11 23:00:00.000',
    723.75238037109398,
    '723.75238037109398'
  )
select * from Logical_tag_data where
uopLogicalTagId='3AF75E96-F354-49E2-97AC-DC9779EE7B5F'
commit tran

return 1
------------------------------------------------------------------------------------

Here is the output:

uopLogicalTagId uopTimeStart
               uopTimeEnd
uopFltValue uopStrValue
                                                                              
                                                                              
                                                                             
uopPercentGood
------------------------------------
------------------------------------------------------
------------------------------------------------------
-----------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------
3AF75E96-F354-49E2-97AC-DC9779EE7B5F 2005-01-11 00:00:00.000
               2005-01-11 23:00:00.000
723.75238037109386 723.75238037109398
                                                                              
                                                                              
                                                                             
NULL

@RETURN_VALUE = 1

After this if I run a simple query (select * from Logical_tag_data where
uopLogicalTagId='3AF75E96-F354-49E2-97AC-DC9779EE7B5F') I don't see the
record I just added. And if I run this stored procedure a second time, again
only 1 record is being displayed. However, if I run the following commands
with the exact same insert everything works fine:

BEGIN TRANSACTION
insert into Logical_Tag_Data
  ( uopLogicalTagId, uopTimeStart, uopTimeEnd, uopFltValue, uopStrValue )
values
  (
    '3AF75E96-F354-49E2-97AC-DC9779EE7B5F',
    '2005-01-11 00:00:00.000',
    '2005-01-11 23:00:00.000',
    723.75238037109398,
    '723.75238037109398'
  )
COMMIT
select * from Logical_tag_data where
uopLogicalTagId='3AF75E96-F354-49E2-97AC-DC9779EE7B5F'

Every time I run it I get an additional record (as expected).

I've tried running the database maintenance to make sure that the database
is not corrupt. And I've tried making a brand new table, but the stored
procudure insert still does not work.

Help!

Thanks,
Mike



Relevant Pages

  • Re: Insert SQL does not work in stored procedure.
    ... You're experiencing 'implicit transaction' mode. ... > On one of our development servers I've run into a problem with Insert ... > command. ... The stored procedure works on other servers and used to work on ...
    (microsoft.public.sqlserver.programming)
  • Re: how to surpress a server error msg?
    ... i'd rather not to change the system stored procedure since that would ... mean i have to change that particular sp on all servers! ... i was calling the sp thru SQL pass thru in Access and return the query ... >> following msg in query analyzer messages tab. ...
    (microsoft.public.sqlserver.server)
  • Re: SQL 2000 Stored Procedure Problem
    ... Are there different rights granted on the two servers? ... context to be the problem with temp tables. ... Five of the 14 routines have been converted to Stored ... just a text string - that worked - so it is not just a Stored Procedure ...
    (microsoft.public.sqlserver.security)
  • Re: order of columns
    ... I was trying to compile a stored procedure to wrap it. ... > needs to be run under the Sysadmin role. ... > servers probably will be running it. ... making was that if I did I'd be manually running it through Query Analyzer ...
    (microsoft.public.sqlserver.programming)
  • Re: sp_ActiveDirectory_Start problem
    ... > I have two Windows 2003 servers that both have SQL 2000 on them with ... If I run the stored procedure ... > only difference that I can see on the servers is that on the one that ... > despite me having run the identical service pack 4 download from MSDN ...
    (comp.databases.ms-sqlserver)