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: From personal aircraft to e-bikes to robots: 5 tech innovations seen at CES Las Vegas Review-Journal Minnesota tech on display at countryās biggest consumer electronics show, with 3M leading the way Star Tribune Time to Finally Organize Your Digital Photos. First You Have to Find Them. - The Wall Street Journal Time to Finally Organize Your Digital Photos. First You Have to Find Them. The Wall Street Journal TOP 10 personal tech and gadgets of 2024 Designboom How AI Will Change Personal Tech in 2025 - Tech News Briefing - WSJ Podcasts The Wall Street Journal Shop the best Cyber Monday deals on phones, tablets, smartwatches and more Good Morning America Tech That Will Change Your Life in 2025 The Wall Street Journal Things to Try: Our 9 Top Tech Tips for You The Wall Street Journal The 28 Best Tech Gifts of 2024, According to Our Gadget Gurus The Wall Street Journal Iāve Been Driving an EV for a Year. I Have Only One Regret. The Wall Street Journal How Tech Created a āRecipe for Lonelinessā The New York Times Can You Turn Off Big Techās A.I. Tools? Sometimes, and Hereās How. The New York Times The Great AI Challenge: We Test Five Top Bots on Useful, Everyday Skills The Wall Street Journal Appleās A.I. Is Landing Soon on iPhones. Hereās What Itās Like. The New York Times Android beefs up Bluetooth tag stalker protections The Register The Coolest Tech Gadgets Weāve Tested So Far This Year BestProducts.com Touch Screens Are Over. Even Apple Is Bringing Back Buttons. The Wall Street Journal Opinion | Why Is Technology Mean to Me? The New York Times The Data Big Tech Companies Have On You Security.org The Summer Is So Hot, Workers Are Wearing High-Tech Ice Packs The Wall Street Journal Apple Watch Is Becoming Doctorsā Favorite Medical Device The Wall Street Journal In the City, Personal Safety Starts With Your Smartphone The Wall Street Journal No way? Big Tech's 'lucrative surveillance' of everyone is terrible for privacy, freedom The Register Why Turning It Off and Turning It Back On Is Gadget-Fixing Magic The Wall Street Journal Apple Intelligence Isnāt Very Smart Yetāand Appleās OK With That The Wall Street Journal What the Arrival of A.I. Phones and Computers Means for Our Data The New York Times China's homebrew Bluetooth alternative is on the march as Beijing pushes universal remotes The Register My Husband Wants a Japanese Toilet. Is He On to Something? The Wall Street Journal How I Got My Attention Span Back The Wall Street Journal How to Add Extra Security Layers to Your Phone or Tablet The New York Times Jonathan Haidt Blamed Tech for Teen Anxiety. Managing the Blowback Has Become a Full-Time Job. The Wall Street Journal The Only App That Always Wins the Battle for Your Attention The Wall Street Journal Exclusive | Wanted: Weekend Warriors in Tech The Wall Street Journal When Did Appleās Notes App Become an Extension of Our Brains? The Wall Street Journal Foldables Are Becoming Good Enough to Be Your Next Smartphone The New York Times Amazon Wants Your Palm and TSA Wants Your Face. What Saying Yes Will Mean. - The Wall Street Journal Amazon Wants Your Palm and TSA Wants Your Face. What Saying Yes Will Mean. The Wall Street Journal How to Reduce Your Risk When Using Personal-Finance Apps The Wall Street Journal This Ring on Your Finger Tracks Your Sleep. Is It Worth the Splurge? The New York Times How to Turn Your Old iPhone Into an A.I. Phone (and Skip the Upgrade) The New York Times Report: Tech misconceptions plague the IT world The Register Tech Made Easy AARP A Case for Backing Up Your Precious Photos and Files at Home The Wall Street Journal I Tried a $1,000 Trash Can for Two Monthsāand I Get It The Wall Street Journal The Battle to Ban Screens From School Now Includes Chromebooks and Tablets - The Wall Street Journal The Battle to Ban Screens From School Now Includes Chromebooks and Tablets The Wall Street Journal The Hearing Aid Revolution That Wasnāt The Wall Street Journal How to Make Typing Easier on the Phone and Leave the Laptop at Home The New York Times China wants mobile devices to limit usage time for minors, ensure they only see nice content The Register Young Women With Eating Disorders Feel the Pull of Energy Drinks The Wall Street Journal How TikTok Is Wiring Gen Zās Money Brain The Wall Street Journal PC shipments stuck in neutral despite AI buzz The Register Welcome to the Era of the A.I. Smartphone The New York Times Slack, Microsoft Teams, Google Chat: Is There Any Safe Place to Complain About Work Online? The Wall Street Journal |
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 |