![]() | |
![]() | |
![]() |
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: Live, Laugh, Logged-On: Women & Personal Technology Getty Images Championing health tech innovation across borders: From personal setbacks to global entrepreneurship Harvard Gazette How to Secure Your Phone’s Data Before Traveling Abroad The New York Times Column | Zuckerberg’s new Meta AI app gets personal in a very creepy way The Washington Post TOP 10 personal tech and gadgets of 2024 Designboom Raspberry Pi slices Compute Module 4 prices theregister.com The Latest Personal Tech at CES 2025- The Accounting Technology Lab Podcast - Jan. 2025 CPA Practice Advisor Personal Enrichment Courses Wake Tech Can Using a Dumber Phone Cure ‘Brain Rot’? The New York Times About National Personal Protective Technology Laboratory Centers for Disease Control and Prevention | CDC (.gov) How Tech Created a ‘Recipe for Loneliness’ The New York Times Why a Tariff-Inflated $2,000 iPhone Is Nothing to Fear The New York Times Google goes cold on Europe: Stops making smart thermostats for continental conditions theregister.com Tech for Babies Is Booming. Here’s What One Parent Found Helped the Most. The New York Times Ignorance really is bliss when you’re drowning in information theregister.com Not a Coder? With A.I., Just Having an Idea Can Be Enough. The New York Times Google wins 1-1: Judge rules ad giant broke some antitrust law theregister.com Top 10 Personal Gadgets For Tech-Savvy Individuals Designed To Revolutionize Their Routine Yanko Design Tech support session saved files, but probably ended a marriage theregister.com A new operating model for people management: More personal, more tech, more human McKinsey & Company Tariff uncertainty looms large over budget conscious CIOs theregister.com How to Spend Less Time on Social Media (or Leave It Altogether) The New York Times Can You Turn Off Big Tech’s A.I. Tools? Sometimes, and Here’s How. The New York Times Apple’s A.I. Is Landing Soon on iPhones. Here’s What It’s Like. The New York Times How to Create a Multimedia Digital Journal of Your Life The New York Times Resellers may be sitting on costly pile of regret after US smartphone shopping spree theregister.com If TikTok Is Here to Stay, What Does That Mean for Us? The New York Times Framework guns for cheap laptops with upgradeable alternative theregister.com Tech Made Easy AARP The passive aggression of connecting USB to PS/2 theregister.com User said he did nothing that explained his dead PC – does a new motherboard count? theregister.com Why You Might Suddenly Be Following Trump on Instagram and Facebook The New York Times Laptop makers stalled on repairability improvements theregister.com Lenovo teases solar-powered and folding screen concept laptops theregister.com The sweet Raspberry taste of success masks a missed opportunity theregister.com Apple and Meta trade barbs over interoperability requests theregister.com This Ring on Your Finger Tracks Your Sleep. Is It Worth the Splurge? The New York Times Wozniak: I didn't reduce chip count for manufacturing. I wanted to prove I was clever theregister.com Hisense QLED TVs are just LED TVs, lawsuit claims theregister.com HP ditches 15-minute wait time policy due to 'feedback' theregister.com Les Paul’s Klunker has been revived as a meticulous one-off replica by Les Paul's personal tech MSN How to Download Your Videos and Other Data From TikTok The New York Times Slack, Microsoft Teams, Google Chat: Is There Any Safe Place to Complain About Work Online? - WSJ WSJ Google says it's rolling out fix for stricken Chromecasts theregister.com Brit watchdog probes Google's search, ads empire theregister.com Android beefs up Bluetooth tag stalker protections theregister.com |
![]() |
![]() |
![]() |
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 |