Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6134645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:22:51+00:00 2026-05-23T17:22:51+00:00

I have a column with a text data type , but its an xml

  • 0

I have a column with a text data type , but its an xml field.When i try to execute a simple statement like

SELECT columnname,
       CONVERT(xml,coloumnname) 
  FROM employee

This is running fine in QA since it has small amount to data. When i am running in the prod then the exception shoots up. Is there a way so that it can bypasses all the records which has an illegal xml character so that i can execute the code successfully. Using sql sever 2005/2008.

do anyone have a scrip for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:22:52+00:00Added an answer on May 23, 2026 at 5:22 pm

    Validate data on-the-fly is slow enough.

    1. If you really do not want to use bad data, you should add column to table (e.g. “Is_Validated”).

    2. Then run script which will check data and if it is converted to xml without exception, update column as 1 else 0.

    3. When you run your statement, you should limit converting to xml where Is_Validated=1 only.

    4. When you insert new row, check if is valid XML (using TRY/CATCH logic or CLR) and insert only valid rows.

    5. When you logic be stable you can begin to validate your bad data.

    Update:

    Because of script from #2 should be run only one time, it can be simple TSQL:
    Assuming you have primary key Id as int and xml column Columnname in Table Employee validated by MySchema

     Declare @id int=0,@xml XML(MySchema)
    WHILE EXISTS(SELECT * FROM Employee WHERE Id>@Id)
    BEGIN
         SELECT TOP 1 @Id=Id FROM Employee WHERE Id>@Id ORDER BY Id
    BEGIN TRY
      SET @xml=(SELECT columnname FROM Employee WHERE id=@Id)
          UPDATE Employee SET Is_Validated=1 WHERE Id=@Id
    END TRY
        BEGIN CATCH
            UPDATE Employee SET Is_Validated=0 WHERE Id=@Id
        END CATCH
        END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem when I try insert some data to Informix TEXT column via
Suppose I have a text file with data separated by whitespace into columns. I
I have a text column with repeated values, for example: | A | ---|---------|
I have a table with a TEXT column where the contents is just strings
I have saved input from a textarea element to a TEXT column in MySQL.
I am using SQL Server 2005. I have a table with a text column
I have a sproc that returns a single line and column with a text,
I have a textbox with the Text property bound to a dataset column with
I have column that contains strings. The strings in that column look like this:
I need a select from table which does not have column that tells when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.