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 2000 Forums
 Transact-SQL (2000)
 How I can make this stored procedure ...

Author  Topic 

Newbie2005
Starting Member

29 Posts

Posted - 2006-03-31 : 17:48:28
How I can make this stored procedure to update if it can not insert this? please help

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


/*
sample input xml
<MessageItemList>
<Id value="2"/>
<Id value="223"/>
</MessageItemList>
*/
ALTER PROCEDURE [dbo].[isp_AddToTag]
( @TagId INT,
@MessageItemXml xml
)
AS
BEGIN
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
SET ARITHABORT ON

INSERT INTO TagMessageMap
SELECT @TagId, T.a.value('@value','int'),GETUTCDATE()
FROM @MessageItemXml.nodes('/MessageItemList/Id') T(a)

END

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-04-01 : 01:29:39
I didnt understood the what do you really want to do.

something like if the following code is not able to insert then you need to write the update statement..

ALTER PROCEDURE [dbo].[isp_AddToTag]
( @TagId INT,
@MessageItemXml xml
)
AS
BEGIN
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
SET ARITHABORT ON

INSERT INTO TagMessageMap
SELECT @TagId, T.a.value('@value','int'),GETUTCDATE()
FROM @MessageItemXml.nodes('/MessageItemList/Id') T(a)

if @@ROWCOUNT=0
Begin

-- Write your update statment here..
End
END

Hope these helps

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page
   

- Advertisement -