Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
174 Points
43 Posts
Jun 01, 2012 05:52 AM|LINK
Create PROCEDURE [dbo].[GetXMLAsInput]
@xmlString varchar(max)
AS
DECLARE @idoc int
DECLARE @ERR Int
SET @ERR = 0
BEGIN
EXEC sp_xml_preparedocument @idoc OUTPUT, @xmlString
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRAN
BEGIN TRY
insert into person (personname,personmobileno,persondob)
SELECT personname,personmobileno,persondob
FROM OPENXML (@idoc, '/NewDataSet/Nodename',2)with (personname varchar(100),personmobileno int ,persondob datetime)
COMMIT TRAN
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK
-- Raise an error with the details of the exception
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
SELECT @ErrMsg = ERROR_MESSAGE(),
@ErrSeverity
= ERROR_SEVERITY()
RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
EXEC sp_xml_removedocument @idoc
--SELECT @ERR
END
sangeetonly
Member
174 Points
43 Posts
Re: how to solve this problem ?
Jun 01, 2012 05:52 AM|LINK
Create PROCEDURE [dbo].[GetXMLAsInput]
@xmlString varchar(max)
AS
DECLARE @idoc int
DECLARE @ERR Int
SET @ERR = 0
BEGIN
EXEC sp_xml_preparedocument @idoc OUTPUT, @xmlString
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRAN
BEGIN TRY
insert into person (personname,personmobileno,persondob)
SELECT personname,personmobileno,persondob
FROM OPENXML (@idoc, '/NewDataSet/Nodename',2)with
(personname varchar(100),personmobileno int ,persondob datetime)
COMMIT TRAN
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK
-- Raise an error with the details of the exception
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
SELECT @ErrMsg = ERROR_MESSAGE(),
@ErrSeverity
= ERROR_SEVERITY()
RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
EXEC sp_xml_removedocument @idoc
--SELECT @ERR
END
("I would love to change the world, but they won’t give me the source code")
Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.