![]() | |
![]() | |
![]() |
Personal Technology Information |
|
![]() |
How to Use SQLXML to Retrieve Data from SQL Server Database?
Using SQL Server 2000 and above versions you can retrieve data from SQL Server in XML format directly from the database. Many XML related features were incorporated in the SQL Server database. This enables the development of XML enabled applications very easy and it makes exchange of data over internet easy. In this article we will discuss about how to use SQLXML to retrieve data directly from SQL server database in XML format. There are some SQL commands and clauses that help you to retrieve data from the SQL Server in the XML format. Syntax for such is given below: SELECT ... FOR XML mode [, XMLDATA] [, ELEMENTS] [, BINARY BASE64] There are different modes and that take the values of · AUTO - In this mode every row of the result of the query forms an element in the returned XML document. · EXPLICIT - This mode defines how to map the columns of the results returned by the query to the XML elements and the attributes. · RAW - All the fields of the result are identified as attributes of an element. · NESTED - The result of this mode is the same as the AUTO mode but the formatting has to be done at the client side. A simple example of using the above syntax is given below: SELECT TOP 3 *FROM (SELECT FirstName+' '+LastName as Name FROM Employees) FOR XML AUTO The query produces this result: Employees Name="John Peter" There are optional parameters in the 'FOR XML mode' clause. The XMLDATA option adds an XSD schema which describes the XML format of the result returned. The ELEMENTS options make the fields of the tables in the database to be returned as child elements. If the ELEMENTS option is not there the fields of the tables are returned as attributes instead of child elements of the XML document. The ELEMENTS option is allowed only in the AUTO mode. The BINARY BASE64 option is used to retrieve any binary data. The returned binary data is returned in BASE64 encoded format. The binary data can be retrieved in the RAW or EXPLICIT mode. An example of the RAW mode is given below: SELECT EmpName, EmpCity from EMP for XML RAW The above code returns a result like, row EmpName="John" EmpCity="New York" In the above result you can note that the fields of the resultset are returned as attributes of the element. .Net provides with managed classes for interacting with SQL Server. The managed classes of SQLXML provided by .Net are: · SqlXmlCommand - This is used to perform queries that are stored in XML documents which are also called XML templates. This class also provides support for client side XML processing. · SqlXmlParameter - this is used to provide parameterized values and is used along with SqlXmlCommand object. · SqlXmlAdapter - this is the adapter class for SQLXML provider. This is used to fill the dataset. · SqlXmlException - this is used to trap the error information from the SQL Server. A sample code using the managed classes is given below. For detailed information on the usage of the above managed classes you can refer to the MSDN documentation. static string cstr = "Provider=SQLOLEDB;Server=(local);database=EmpPersonal;";public static void testingSqlXml (){ Stream oStr = Console.OpenStandardOutput(); SqlXmlCommand sqlcmd = new SqlXmlCommand(cstr); sqlcmd.Root = "Employees"; sqlcmd.CommandType = SqlXmlCommandType.Sql; sqlcmd.CommandText = "SELECT EmpName, EmpCity FROM Employees FOR XML AUTO"; strm = sqlcmd.ExecuteToStream(oStr); oStr.Close();} Thus we have seen that SQLXML can be used to retrieve data directly from the SQL Server in XML format. It is easy to handle and transmit data through the internet if it is in the XML format and this can be easily achieved using the SQLXML. Want to stay current with the latest technology developments realted to XML. Visit Free XML Tutorial to get your FREE subscription now! ** Attention Webmasters / Website Owners ** You can reprint this article on your website as long as you do not modify any of the content, and include our resource box as listed above with all links intact and hyperlinked properly.
MORE RESOURCES: I Quit Google Search for AI—and I’m Not Going Back The Wall Street Journal If TikTok Is Here to Stay, What Does That Mean for Us? The New York Times TOP 10 personal tech and gadgets of 2024 Designboom The Latest Personal Tech at CES 2025- The Accounting Technology Lab Podcast - Jan. 2025 CPAPracticeAdvisor.com The Five Things You Shouldn’t Tell ChatGPT The Wall Street Journal Personal Enrichment Courses Wake Tech Newsroom Tech for Babies Is Booming. Here’s What One Parent Found Helped the Most. The New York Times Not a Coder? With A.I., Just Having an Idea Can Be Enough. The New York Times AI Solves My Most Annoying Chore: Meal Planning for a Toddler The Wall Street Journal How Workplace Tech Has Changed Over the Years, From the WSJ Archives The Wall Street Journal How Tech Created a ‘Recipe for Loneliness’ The New York Times Tech That Will Change Your Life in 2025 - WSJ The Wall Street Journal iRobot may be iDead in iYear The Register The Trouble With Searching Google for ‘the Best’ The Wall Street Journal The Snapchat Move That Leaves Teen Girls Heartbroken The Wall Street Journal When Cell Service Is Down, You Can Send iPhone Texts via Satellite The Wall Street Journal How to Create a Multimedia Digital Journal of Your Life The New York Times Office Technology Comes to the Movies: Test Your Knowledge With Our Quiz The Wall Street Journal Top 10 Personal Gadgets For Tech-Savvy Individuals Designed To Revolutionize Their Routine Yanko Design Your iPhone Storage Is Full Again. Do This to Reclaim Space. The Wall Street Journal Shop the best Cyber Monday deals on phones, tablets, smartwatches and more Good Morning America The 28 Best Tech Gifts of 2024, According to Our Gadget Gurus The Wall Street Journal ChatGPT vs. Claude vs. DeepSeek: The Battle to Be My AI Work Assistant - WSJ The Wall Street Journal Can an App Replace a Personal Trainer? I Tested Nearly a Dozen to Find Out - The Wall Street Journal Can an App Replace a Personal Trainer? I Tested Nearly a Dozen to Find Out The Wall Street Journal Tech Made Easy AARP Things to Try: Our 9 Top Tech Tips for You The Wall Street Journal Can You Turn Off Big Tech’s A.I. Tools? Sometimes, and Here’s How. The New York Times How to Make Typing Easier on the Phone and Leave the Laptop at Home The New York Times The Summer Is So Hot, Workers Are Wearing High-Tech Ice Packs The Wall Street Journal Touch Screens Are Over. Even Apple Is Bringing Back Buttons. - WSJ The Wall Street Journal Apple Intelligence Isn’t Very Smart Yet—and Apple’s OK With That - WSJ The Wall Street Journal I Replied ‘Stop’ to a Political Text Message. I Got 100 More. - WSJ The Wall Street Journal The Coolest Tech Gadgets We Recommend for 2025 BestProducts.com Wozniak: I didn't reduce chip count for manufacturing. I wanted to prove I was clever - The Register The Year Everyone Started ‘Manifesting.’ Does It Work? The Wall Street Journal Apple’s A.I. Is Landing Soon on iPhones. Here’s What It’s Like. The New York Times User said he did nothing that explained his dead PC – does a new motherboard count? - The Register Want an iPhone 16 Review? Just Ask Joannabot The Wall Street Journal What the Arrival of A.I. Phones and Computers Means for Our Data The New York Times Apple Watch Is Becoming Doctors’ Favorite Medical Device - WSJ The Wall Street Journal This Ring on Your Finger Tracks Your Sleep. Is It Worth the Splurge? The New York Times How to Download Your Videos and Other Data From TikTok The New York Times Apple Headset Stalls, Struggles to Attract Killer Apps in First Year The Wall Street Journal The Only App That Always Wins the Battle for Your Attention The Wall Street Journal No way? Big Tech's 'lucrative surveillance' of everyone is terrible for privacy, freedom The Register Android beefs up Bluetooth tag stalker protections The Register The Great AI Challenge: We Test Five Top Bots on Useful, Everyday Skills The Wall Street Journal Laptop makers stalled on repairability improvements The Register PC shipments stuck in neutral despite AI buzz The Register Exclusive | Google’s Gemini Live AI Sounds So Human, I Almost Forgot It Was a Bot The Wall Street Journal Why You Might Suddenly Be Following Trump on Instagram and Facebook The New York Times I’ve Been Driving an EV for a Year. I Have Only One Regret. - WSJ The Wall Street Journal Running Your Household Is a Second Job, but It Doesn’t Have to Be The Wall Street Journal Brit watchdog probes Google's search, ads empire The Register |
![]() |
![]() |
![]() |
RELATED ARTICLES
Is Desktop Search Deserving? Google, in their march to stay ahead of the pack of competition, has released Google Desktop Search. With Microsoft's MSN in the lead position and nipping at Google's heels, and Google's new shareholders to please, Google has more incentive than ever to deploy technology both better than the other guy's, and sooner. 10 Time Saving Keyboard Shortcuts Time is money. And when you constantly have to divide your time between your mouse and your keyboard, your workflow rate really slows down. Image Conversion In Computers JPEG, GIFF/JIFF, BMP, and TIFF are the most commonly used formats for storing still image files such as photographs, graphics, and drawings.JPEG stands for Joint Photographic Experts Group and is a standard for image compression. Palm PC critique I met an entrepreneur who hole heartedly disagree with an article in Advertising Age by Bradley Johnson that Palm Pilot can keep their market share through brand name. We discussed RIMM Research in Motion and my stock in that company and I defended the wireless venue, but he went into a tirade, luckily I used a digital recorder and got most of it; basically here is his critique:"That grip has already eroded by Palm PC makers and clones. How Does My PC Get Hot There are many sources of heat that can raise the temperature in your PC. No, I'm not talking about the Tabasco sauce you dripped over your keyboard when you ate that bowl of chili at your desk, and no, I'm not talking about that Pamela Anderson (or Ricky Martin poster, depending on your taste) above your desk. Why Build Your Own Computer System Have you ever thought about building your own computer system? Maybe you've heard friends talking about doing this sort of thing, but you were never sure what was involved. This article attempts to answer two questions. Your Affiliate Business - Peripherals, Software, Computers I have always been interested in computers, but in the beginning, I would not venture any further than to the software end of learning. However, learning only the software side, and knowing nothing about the hardware side, can open you up to some costly times at the shop. How To Increase Computer Speed And Performance - Great Tips & Tricks Many computer users are worried about their computer's performance. After spending lot of bucks, still they cannot have that charm of using PC as they had expected. Cisco Certification: A Survival Guide To The Cisco Cable Jungle One of the most confusing parts of beginning your Cisco studies is keeping all the cable types separate in your mind, and then remembering what they're used for. This often occurs when a CCNA or CCNP candidate starts putting together their own home practice lab, and they suddenly realize that they have the equipment to run labs, but not the cables. Troubleshooting Computer Freeze (Lockup) Problems How familiar does the following sound? Your computer was working fine, but then suddenly started locking up (aka hanging or freezing), rebooting itself (crashing) or shutting down spontaneously? If you know only too well what I am talking about, then read on! Performing the simple steps below can fix the majority of lockup cases.1. How to Place Home Theater Speakers You have your television and home theater receiver; you just bought your new speakers and subwoofer and are ready to test things out. It's time to break out the measuring tape because precision is vital to achieving the full potential of your home theater system. A Peek Into the Near Future of Electronics Technology How long do you think DVDs have around? 20 years? 10 years? Actually, they have only been around for about seven years, but it seems like they have been around much longer. Many of us can hardly remember life before DVDs. Font Organizers Review, Part I Do you know how many fonts are currently installed on your PC? What is the difference between OpenType, TrueType, PostScript Type 1 and Printer fonts? If the answer is 'No', it's time to consider getting a font organizer.TypografThis extremely well-done 32-bit app lets you preview, print, and manage TrueType and Type 1 fonts. Help, I Need a New HDTV! (Part 4 of 5) Feeling overwhelmed in selecting a new TV? With all the choices these days, you may feel like, "Where do I start?!"In part 4 of our 5 part article, we the discuss "do I really need an HDTV?"---Right now, stations are moving towards HDTV programming. Although available for free over the air in major metropolitan areas, this process will take a few years to fully unfold. Printing Multiple Copies of Photos I do a holiday letter every year and send them to friends so they know what's happening with my family and I ask them about theirs. Though addressing the envelopes and such is a pain, I enjoy doing the letter and adding a wallet-sized photo of my kids to show them off. Quick System Restore with ASR Backups ASR (Automated System Recovery) is a feature available on the Windows XP Pro and Windows Server 2003 operating systems for quick and efficient system backup and restore.Typically, the restore process involves reinstalling the operating system and configuring all physical storage to their original settings before restoring data and settings. PC Tools Youd Never Think You Need Do you use Windows standard uninstall feature? How do you migrate data from your old PC to the new one? Get some tips on amazing software you never knew existed and find out why the pros have been using them for years.Ashampoo UnInstaller SuiteThe question is, why should this be necessary at all? Why do you need a special program? Why can't you just delete an application in the same way you can delete a file? The full answer to this question could fill a book. Basic Computer Maintenance One of the most common questions computer users ask is, "How do I maintain my computer and keep it running great?" A computer is a lot like a car?it costs more than you think it should, it starts going down in value as soon as you bring it home and it requires regular maintenance to keep it running smoothly. Here are a few basic guidelines required to help keep your PC out of the shop:?Always use a surge protector! Power surges, spikes, lightning and brown-outs are all things that can literally burn up your computer & its peripherals. How to Buy a Plasma Television Set Most people think that all you have to do to purchase a new plasma television set is to walk into a shop, look around, and purchase the first set that catches your attention. This is how you're supposed to do it, right? Wrong! Buying a television, whether it has a plasma monitor or a LCD monitor, takes careful planning. What Does That Error Message Really Mean? Surf the 'Net for about 10 minutes and chances rate veryhigh that you'll encounter an error of one kind oranother.Whether the error message pops up on your own computer oron a website loaded in your browser, knowing what theerror means can help you solve the problem much fasterand avoid hours of frustration (especially in a situationwhere nothing you do will solve the problem). ![]() |
home | site map |
© 2006 |