﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Leon Platt / Article Discussions / Article Discussions by Author </title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 24 May 2012 12:42:35 GMT</lastBuildDate><ttl>20</ttl><item><title>regarding ajax</title><link>http://www.sqlservercentral.com/Forums/Topic669257-28-1.aspx</link><description>i am using ajaxany one knoe how to get the xml response using ajax</description><pubDate>Thu, 05 Mar 2009 08:05:15 GMT</pubDate><dc:creator>rajapcs</dc:creator></item><item><title>Making Dynamic Queries Static</title><link>http://www.sqlservercentral.com/Forums/Topic3839-28-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/lplatt/makingdynamicqueriesstatic.asp&gt;http://www.sqlservercentral.com/columnists/lplatt/makingdynamicqueriesstatic.asp&lt;/A&gt;</description><pubDate>Sun, 28 Apr 2002 00:00:00 GMT</pubDate><dc:creator>Leon Platt</dc:creator></item><item><title>ASP - Reaping the benifits of SQL 2000's FOR XML clause.</title><link>http://www.sqlservercentral.com/Forums/Topic1515-28-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/lplatt/article4_1.asp&gt;http://www.sqlservercentral.com/columnists/lplatt/article4_1.asp&lt;/A&gt;</description><pubDate>Sun, 04 Nov 2001 00:00:00 GMT</pubDate><dc:creator>Leon Platt</dc:creator></item><item><title>RE:</title><link>http://www.sqlservercentral.com/Forums/Topic175025-28-1.aspx</link><description>&lt;P&gt;This was an excellent "quick tutorial" on XML.&lt;/P&gt;&lt;P&gt;I would add, that there is something you can do with all that XML too.&lt;/P&gt;&lt;P&gt;Especially since this is the "sqlserver"central website.&lt;/P&gt;&lt;P&gt;Here is an example using the code supplied:&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;if exists (select * from sysobjects  where id = object_id('Content')) DROP TABLE Content&lt;/P&gt;&lt;P&gt;if exists (select * from sysobjects  where id = object_id('Cup')) DROP TABLE Cup&lt;/P&gt;&lt;P&gt;CREATE TABLE dbo.Cup (&lt;/P&gt;&lt;P&gt;        cupid int IDENTITY (1,1) PRIMARY KEY NONCLUSTERED, --self explanatory&lt;/P&gt;&lt;P&gt; materialname varchar(64) NULL ,  materialtrans varchar(8) NULL , &lt;/P&gt;&lt;P&gt; height varchar(64) NULL ,  heightunits varchar(64) NULL , &lt;/P&gt;&lt;P&gt; volume varchar(64) NULL ,   volumeunits varchar(64) NULL , &lt;/P&gt;&lt;P&gt; haslid varchar(8) NULL ,    createdate datetime DEFAULT getDATE())&lt;/P&gt;&lt;P&gt;GO&lt;/P&gt;&lt;P&gt;CREATE TABLE dbo.Content (&lt;/P&gt;&lt;P&gt;        contentid int IDENTITY (1,1) PRIMARY KEY NONCLUSTERED, --self explanatory&lt;/P&gt;&lt;P&gt; cupid int NOT NULL  FOREIGN KEY (cupid) REFERENCES dbo.Cup(cupid), -- contenttype varchar(64) NULL ,  contentname varchar(64) NULL ,  quantity int NOT NULL DEFAULT 0,&lt;/P&gt;&lt;P&gt; createdate datetime DEFAULT getDATE())&lt;/P&gt;&lt;P&gt;GO&lt;/P&gt;&lt;P&gt;print 'Tabled Created'&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;if exists (select * from sysobjects  where id = object_id('dbo.uspCreateCups') and sysstat &amp;amp; 0xf = 4) drop procedure dbo.uspCreateCupsGO&lt;/P&gt;&lt;P&gt;CREATE Procedure dbo.uspCreateCups( @xml_doc text)&lt;/P&gt;&lt;P&gt;AS &lt;/P&gt;&lt;P&gt;set nocount ON&lt;/P&gt;&lt;P&gt;DECLARE @idoc int--Sample XML document&lt;/P&gt;&lt;P&gt;--Create an internal representation of the XML document.exec sp_xml_preparedocument @idoc OUTPUT, @xml_doc-- SELECT statement using OPENXML rowset provider&lt;/P&gt;&lt;P&gt;--Create a variable table to insert the values--this allows a bulk insert laterDECLARE @myvariabletableCups table( materialname varchar(64) NULL ,  materialtrans varchar(8) NULL ,  height varchar(64) NULL ,  heightunits varchar(64) NULL ,  volume varchar(64) NULL ,   volumeunits varchar(64) NULL ,  haslid varchar(8) NULL )&lt;/P&gt;&lt;P&gt;DECLARE @myvariabletableContent table(&lt;/P&gt;&lt;P&gt; contenttype varchar(64) NULL ,  contentname varchar(64) NULL ,  quantity int NOT NULL DEFAULT 0)&lt;/P&gt;&lt;P&gt;/*&amp;lt;CUP&amp;gt;&amp;lt;MATERIAL transparent="yes"&amp;gt;glass&amp;lt;/MATERIAL&amp;gt;&amp;lt;HEIGHT units="inches"&amp;gt;6&amp;lt;/HEIGHT&amp;gt;&amp;lt;VOLUME units="ounces"&amp;gt;16&amp;lt;/VOLUME&amp;gt;&amp;lt;CONTENTS&amp;gt; &amp;lt;SOLID qty="2"&amp;gt;ice cube&amp;lt;/SOLID&amp;gt; &amp;lt;SOLID qty="1"&amp;gt;straw&amp;lt;/SOLID&amp;gt; &amp;lt;LIQUID qty="3" units="ounces"&amp;gt;water&amp;lt;/LIQUID&amp;gt; &amp;lt;OTHER qty="0"/&amp;gt;&amp;lt;/CONTENTS&amp;gt;&amp;lt;LID&amp;gt;yes&amp;lt;/LID&amp;gt;&amp;lt;/CUP&amp;gt;*/&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;--but only the needed data is actually inserted into the real tablesINSERT INTO @myvariabletableCupsSELECT materialname , materialtrans  ,  height ,  heightunits  ,  volume  ,   volumeunits  ,  haslid &lt;/P&gt;&lt;P&gt;FROM     OPENXML (@idoc, '/CUP',2) --The "2" means something.  See Books Online.        WITH  (   materialname varchar(64) './MATERIAL' , materialtrans varchar(64) &lt;A href="mailto:'./MATERIAL/@transparent'"&gt;'./MATERIAL/@transparent'&lt;/A&gt; ,  height varchar(64)  './HEIGHT',  heightunits varchar(64)  &lt;A href="mailto:'./HEIGHT/@units'"&gt;'./HEIGHT/@units'&lt;/A&gt;,  volume varchar(64) './VOLUME',  volumeunits varchar(64)   &lt;A href="mailto:'./VOLUME/@units'"&gt;'./VOLUME/@units'&lt;/A&gt;,  haslid varchar(8)   './LID'&amp;nbsp&lt;img src='images/emotions/wink.gif' height='20' width='20' border='0' title='Wink' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;print '&amp;lt; select * from @myvariabletableCups &amp;gt;'select * from @myvariabletableCups&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;INSERT INTO @myvariabletableContentSELECT 'SOLID, not perfect example with in-consistent Xpath'  ,  contentname  ,  quantity &lt;/P&gt;&lt;P&gt;FROM     OPENXML (@idoc, '/CUP/CONTENTS/SOLID',2) --The "2" means something.  See Books Online.        WITH  (   contenttype varchar(64)  , contentname varchar(64) '.' ,  quantity varchar(64)  &lt;A href="mailto:'./@qty'"&gt;'./@qty'&lt;/A&gt; &amp;nbsp&lt;img src='images/emotions/wink.gif' height='20' width='20' border='0' title='Wink' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt;print '&amp;lt; select * from @myvariabletableContent &amp;gt;'select * from @myvariabletableContent&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;BEGIN TRAN&lt;/P&gt;&lt;P&gt;INSERT INTO dbo.Cup (    materialname , materialtrans  ,  height ,  heightunits  ,  volume  ,   volumeunits  ,  haslid &amp;nbsp&lt;img src='images/emotions/wink.gif' height='20' width='20' border='0' title='Wink' align='absmiddle'&gt;SELECT  materialname , materialtrans  ,  height ,  heightunits  ,  volume  ,   volumeunits  ,  haslid &lt;/P&gt;&lt;P&gt;FROM @myvariabletableCups&lt;/P&gt;&lt;P&gt;DECLARE @cupJustInsertedIdentity intSELECT @cupJustInsertedIdentity = IDENT_CURRENT('dbo.Cup')&lt;/P&gt;&lt;P&gt;if (@cupJustInsertedIdentity IS NOT NULL) BEGIN&lt;/P&gt;&lt;P&gt;  INSERT INTO dbo.Content    (   cupid ,   contenttype ,    contentname  ,    quantity   &amp;nbsp&lt;img src='images/emotions/wink.gif' height='20' width='20' border='0' title='Wink' align='absmiddle'&gt;  SELECT   @cupJustInsertedIdentity ,    contenttype ,    contentname  ,    quantity     FROM       @myvariabletableContent&lt;/P&gt;&lt;P&gt; END&lt;/P&gt;&lt;P&gt;IF @@ERROR &amp;lt;&amp;gt; 0      BEGIN        RAISERROR('insert error', 16, 1)    ROLLBACK Transaction END ELSE BEGIN  COMMIT TRAN END&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;print '&amp;lt; select * from dbo.Cup &amp;gt;'select * from dbo.Cup&lt;/P&gt;&lt;P&gt;print '&amp;lt; select * from dbo.Content &amp;gt;'select * from dbo.Content&lt;/P&gt;&lt;P&gt;SET NOCOUNT OFF&lt;/P&gt;&lt;P&gt;GO&lt;/P&gt;&lt;P&gt;print 'Procedure Created'&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Now, to use it:&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;EXEC dbo.uspCreateCups'&amp;lt;?xml version="1.0"?&amp;gt;&amp;lt;CUP&amp;gt;&amp;lt;MATERIAL transparent="yes"&amp;gt;glass&amp;lt;/MATERIAL&amp;gt;&amp;lt;HEIGHT units="inches"&amp;gt;6&amp;lt;/HEIGHT&amp;gt;&amp;lt;VOLUME units="ounces"&amp;gt;16&amp;lt;/VOLUME&amp;gt;&amp;lt;CONTENTS&amp;gt; &amp;lt;SOLID qty="2"&amp;gt;ice cube&amp;lt;/SOLID&amp;gt; &amp;lt;SOLID qty="1"&amp;gt;straw&amp;lt;/SOLID&amp;gt; &amp;lt;LIQUID qty="3" units="ounces"&amp;gt;water&amp;lt;/LIQUID&amp;gt; &amp;lt;OTHER qty="0"/&amp;gt;&amp;lt;/CONTENTS&amp;gt;&amp;lt;LID&amp;gt;yes&amp;lt;/LID&amp;gt;&amp;lt;/CUP&amp;gt;' &lt;/P&gt;</description><pubDate>Fri, 15 Apr 2005 09:21:00 GMT</pubDate><dc:creator>sholliday</dc:creator></item><item><title>ASP and ADO Gotcha - Duplicate Field Names in a Query</title><link>http://www.sqlservercentral.com/Forums/Topic581-28-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/lplatt/aspandadogotchaduplicatefieldnamesinaquery.asp&gt;http://www.sqlservercentral.com/columnists/lplatt/aspandadogotchaduplicatefieldnamesinaquery.asp&lt;/A&gt;</description><pubDate>Mon, 16 Jul 2001 00:00:00 GMT</pubDate><dc:creator>Leon Platt</dc:creator></item><item><title>Pseudo web service using xmlHTTP</title><link>http://www.sqlservercentral.com/Forums/Topic580-28-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/lplatt/pseudowebserviceusingxmlhttp_1.asp&gt;http://www.sqlservercentral.com/columnists/lplatt/pseudowebserviceusingxmlhttp_1.asp&lt;/A&gt;</description><pubDate>Mon, 16 Jul 2001 00:00:00 GMT</pubDate><dc:creator>Leon Platt</dc:creator></item><item><title>ASP - reaping the benifits of SQL 2000&amp;#39;s FOR XML </title><link>http://www.sqlservercentral.com/Forums/Topic1514-28-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=article4.htm&gt;article4.htm&lt;/A&gt;</description><pubDate>Sun, 04 Nov 2001 00:00:00 GMT</pubDate><dc:creator>Leon Platt</dc:creator></item></channel></rss>
