302 Part I EXAM PREPARATION So, now you

302 Part I EXAM PREPARATION So, now you have the data you want, extracted from an XML rowset. Using the WITH clause is basically the same syntax as laying out the columns in a table: the column name, some space, the data type, a comma, and then the next column name. IN THE FIELD XML PARSERS If the OPENXML stuff looks like it s extremely cumbersome to deal with, there s a good reason for it. It is extremely cumbersome. You can t read the XML in from a file very easily; you have to spend a huge amount of time fighting with arcane bit-field flags, and you get to completely reformat your data using a WITH option. And you do all that just to get a few rows out, because you can t declare a variable of type TEXT, so you can hold only about 8KB of XML in SQL Server at a time. Learn this stuff for the test. If you are ever involved in a project that requires you to import XML, use any of about five readily available scripting languages (Perl, VBScript, Java, Python, and C# come to mind, and there are probably dozens more), parse the XML using the already written, elegant, and useful tools in those languages tools that are specifically designed to parse XML and have the scripts write out nice, comma- (or something) delimited text. You ll learn how to import that in the next section. That way, you don t have to worry about getting memory leaks in SQL Server, and you don t need to be concerned about running this a thousand times to get all your data in 8KB at a time. Well, the syntax stays the same until you decide you don t want a column called FirstName; you d rather have columns called FName and LName. So, now what? SELECT * FROM openxml(@hdoc, /Person , 1) WITH (FName varchar(30) @FirstName , LName varchar(30) @LastName ) Now you end up with a nice, clean rowset. You need to look at one more thing for the exam. Imagine that you want to output something farther up the tree from where you specify the rowpattern.

If you looking for unlimited one inclusive web hosting plan please check unlimited web hosting website.

Comments are closed.