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

  • Home
  • SEARCH
  • 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 7833695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:50:47+00:00 2026-06-02T12:50:47+00:00

SELECT @Name = Name FROM Table FOR XML AUTO Does not work, how do

  • 0
   SELECT @Name = Name FROM Table FOR XML AUTO

Does not work, how do you get the XML result from using FOR XML into a variable?

  • 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-06-02T12:50:48+00:00Added an answer on June 2, 2026 at 12:50 pm

    This will work:

    SELECT @Name = CONVERT(XML, (
      SELECT Name
      FROM SomeTable
      FOR XML AUTO
    ));
    

    You can try it without the wrapping CONVERT(XML, (...)) statement but I’ve found that SQL Server doesn’t like assigning to XML variables without that explicit cast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using VB6 and Access 2003 Query Select Temp.* into NewTable from Temp Table Name
I'm trying to insert some data from a XML document into a variable table.
Let's say I have SELECT name FROM table which gives me something like foo
When using this SQL query: Select * from table_name what happens if the name
I am searching for records in a table as follows: SELECT Id, Name FROM
I have the following table Select * from Peeps Id Name Age 1 Sam
Is there a way to get this XML from select * from ANY_TABLE query?
I am selecting from a table that has an XML column using T-SQL. I
I'm getting the same results from select length(column_name) from table as from select dbms_lob.getlength(column_name)
I have two queries, as following: SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name

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.