<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-1635568622827949164.post6398656063312772604..comments</id><updated>2010-02-03T09:59:59.678+11:00</updated><title type='text'>Comments on cloud.net: SharePoint List in SQL</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.ray1.net/feeds/6398656063312772604/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default'/><link rel='alternate' type='text/html' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html'/><author><name>Ray Proffitt</name><uri>http://www.blogger.com/profile/15949105136667510991</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1635568622827949164.post-6525397716505031503</id><published>2010-02-03T09:59:59.678+11:00</published><updated>2010-02-03T09:59:59.678+11:00</updated><title type='text'>Thanks Ray.

I incorporated your suggestions and I...</title><content type='html'>Thanks Ray.&lt;br /&gt;&lt;br /&gt;I incorporated your suggestions and I think this works now: &lt;br /&gt;&lt;br /&gt;ALTER procedure [dbo].[usp_PrintList] (@ListId uniqueidentifier)&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;    &lt;br /&gt;    DECLARE @XMLFields TABLE (Row INT IDENTITY, Field XML);&lt;br /&gt; DECLARE @xFields XML; &lt;br /&gt; SELECT @xFields = (SELECT tp_Fields as XML&lt;br /&gt;      FROM Lists &lt;br /&gt;      WHERE (tp_ID = @ListId))&lt;br /&gt; &lt;br /&gt;  INSERT INTO  @XMLFields&lt;br /&gt;    SELECT Tbl.xFlds.query(&amp;#39;.&amp;#39;) from @xFields.nodes(&amp;#39;/Field&amp;#39;) as Tbl(xFlds)&lt;br /&gt; &lt;br /&gt;  DECLARE @sql VARCHAR(MAX), @field XML, &lt;br /&gt;    @colname VARCHAR(30), @Type VARCHAR(30), @dispname VARCHAR(255);&lt;br /&gt;  &lt;br /&gt;  SET @sql = &amp;#39;SELECT t1.tp_ID as [ID], &amp;#39;&lt;br /&gt; &lt;br /&gt;  DECLARE tmpCursor CURSOR FOR&lt;br /&gt;    SELECT Field, &amp;#39;t1.&amp;#39;+ Field.value(&amp;#39;(/Field/@ColName)[1]&amp;#39;, &amp;#39;varchar(max)&amp;#39;) , &lt;br /&gt;      Field.value(&amp;#39;(/Field/@Type)[1]&amp;#39;, &amp;#39;varchar(max)&amp;#39;), &lt;br /&gt;      &amp;#39; as [&amp;#39;+ isnull(Field.value(&amp;#39;(/Field/@DisplayName)[1]&amp;#39;, &amp;#39;varchar(max)&amp;#39;), &lt;br /&gt;      Field.value(&amp;#39;(/Field/@Name)[1]&amp;#39;, &amp;#39;varchar(max)&amp;#39;)) +&amp;#39;], &amp;#39;&lt;br /&gt;    FROM @XMLFields&lt;br /&gt; &lt;br /&gt;  OPEN tmpCursor&lt;br /&gt;  FETCH NEXT FROM tmpCursor INTO @field, @colname, @Type, @dispname&lt;br /&gt;    WHILE @@FETCH_STATUS = 0&lt;br /&gt;    BEGIN&lt;br /&gt;      IF(@colname IS NOT NULL)&lt;br /&gt;      BEGIN  &lt;br /&gt; &lt;br /&gt;        SET @sql = (CASE @Type&lt;br /&gt;          WHEN &amp;#39;Lookup&amp;#39; THEN &lt;br /&gt;            @sql + &amp;#39;(SELECT nvarchar1 FROM UserData WHERE tp_ListId = &amp;#39;&amp;#39;&amp;#39;+ &lt;br /&gt;            (@field.value(&amp;#39;(/Field/@List)[1]&amp;#39;, &amp;#39;varchar(max)&amp;#39;)) +&lt;br /&gt;            &amp;#39;&amp;#39;&amp;#39; AND tp_ID = &amp;#39;+ @colname +&amp;#39;)&amp;#39; + @dispname    &lt;br /&gt;          &lt;br /&gt;          WHEN &amp;#39;User&amp;#39; THEN &lt;br /&gt;            @sql + &amp;#39;(SELECT Top 1 tp_Title FROM &lt;br /&gt;            UserInfo WHERE tp_ID = &amp;#39;+ @colname +&amp;#39;)&amp;#39; + @dispname            &lt;br /&gt;          &lt;br /&gt;          ELSE @sql + @colname + @dispname&lt;br /&gt;          END)&lt;br /&gt;  &lt;br /&gt;      END&lt;br /&gt;      FETCH NEXT FROM tmpCursor INTO @field, @colname, @Type, @dispname&lt;br /&gt;    END&lt;br /&gt;  CLOSE tmpCursor&lt;br /&gt;  DEALLOCATE tmpCursor  &lt;br /&gt;   &lt;br /&gt;  --strip off last comma&lt;br /&gt;  SET @sql = SUBSTRING( RTRIM(@sql), 1, LEN(@sql) - 1 )&lt;br /&gt;  SET @sql = @sql + &amp;#39; FROM UserData t1 WHERE t1.tp_ListId = &amp;#39;&amp;#39;&amp;#39;+ &lt;br /&gt;      CAST(@ListId AS VARCHAR(50)) +&amp;#39;&amp;#39;&amp;#39; AND t1.tp_RowOrdinal = 0 ORDER BY t1.tp_ID asc&amp;#39;&lt;br /&gt; &lt;br /&gt;  PRINT @sql&lt;br /&gt;  EXEC(@sql)&lt;br /&gt; &lt;br /&gt;END</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/6525397716505031503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/6525397716505031503'/><link rel='alternate' type='text/html' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html?showComment=1265151599678#c6525397716505031503' title=''/><author><name>David J. Kon</name><uri>http://www.blogger.com/profile/13867492484808507469</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html' ref='tag:blogger.com,1999:blog-1635568622827949164.post-6398656063312772604' source='http://www.blogger.com/feeds/1635568622827949164/posts/default/6398656063312772604' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-1635568622827949164.post-6014474126082772257</id><published>2010-02-03T09:41:35.659+11:00</published><updated>2010-02-03T09:41:35.659+11:00</updated><title type='text'>David.

1.- From the err msg, the xml string appea...</title><content type='html'>David.&lt;br /&gt;&lt;br /&gt;1.- From the err msg, the xml string appears to be truncated/incomplete.&lt;br /&gt;I can you modify the proc to print out the variable values, to see where and when it breaks?&lt;br /&gt;&lt;br /&gt;2.- Without knowing your list schema it&amp;#39;s hard to be sure; but it looks like some of your lookups may have more than one value; which I didn&amp;#39;t cater for.&lt;br /&gt;You could do a &amp;quot;Select top 1&amp;quot; in the subqueries or try and concatenate the return rows in to a comma delimited varchar variable and with an &amp;quot;IN()&amp;quot;.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/6014474126082772257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/6014474126082772257'/><link rel='alternate' type='text/html' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html?showComment=1265150495659#c6014474126082772257' title=''/><author><name>Ray Proffitt</name><uri>http://www.blogger.com/profile/15949105136667510991</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='10484134206468661863'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html' ref='tag:blogger.com,1999:blog-1635568622827949164.post-6398656063312772604' source='http://www.blogger.com/feeds/1635568622827949164/posts/default/6398656063312772604' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-1635568622827949164.post-3198365499922439506</id><published>2010-02-03T07:05:08.294+11:00</published><updated>2010-02-03T07:05:08.294+11:00</updated><title type='text'>I aslo get this error on soem lists: (46 row(s) af...</title><content type='html'>I aslo get this error on soem lists: (46 row(s) affected)&lt;br /&gt;SELECT t1.nvarchar1 as [Summary], t1.nvarchar3 as [Group], t1.ntext2 as [Description], t1.ntext3 as [Business Case], (SELECT tp_Title FROM &lt;br /&gt;            UserInfo WHERE tp_ID = t1.int1) as [Requestor], (SELECT nvarchar1 FROM UserData WHERE tp_ListId = &amp;#39;{d3576909-5291-4bf1-ae4c-b991c86d5245}&amp;#39; AND tp_ID = t1.int2) as [Business Owner], t1.nvarchar4 as [Priority], (SELECT tp_Title FROM &lt;br /&gt;            UserInfo WHERE tp_ID = t1.int3) as [Assigned To], t1.nvarchar5 as [Request Type], (SELECT nvarchar1 FROM UserData WHERE tp_ListId = &amp;#39;{def12deb-02cf-4178-bf53-1bd691e5fe97}&amp;#39; AND tp_ID = t1.int4) as [Category or System], t1.nvarchar6 as [Status], t1.ntext4 as [Status Text], t1.datetime1 as [Status Text Date], t1.nvarchar7 as [Effort], t1.float1 as [%Complete], t1.datetime2 as [Target Date], t1.datetime4 as [Start Date], t1.datetime3 as [Completed Date], t1.float2 as [Parent Request ID], t1.float3 as [Parent Task ID], t1.float4 as [Task ID], t1.nvarchar8 as [Copy IM Request Task ID], t1.nvarchar9 as [IM Request Tasks - Status Text Copy and Date Stamp], t1.nvarchar10 as [Copy IM Request Task ID and copy request date], t1.nvarchar11 as [IM Task Closed - Notify for Request Closure], t1.nvarchar12 as [Assigned To Person Notification], t1.bit1 as [Assigned To Person?], t1.nvarchar13 as [Assigned To Person Notification (2)], t1.nvarchar14 as [Email Notification To All Groups], t1.bit2 as [Approved Close?], t1.nvarchar15 as [Assigned To Person Notification (3)], t1.nvarchar16 as [Email Notification To All Groups (2)], t1.tp_ContentType as [Content Type], t1.datetime5 as [Request Date], t1.nvarchar17 as [Task Closure Data Cleanup], t1.nvarchar18 as [Task Closure Data Cleanup (2)], t1.nvarchar20 as [IM Task Closed - Notify for Request Closure], t1.sql_variant1 as [Date Closed Plus 8], t1.nvarchar19 as [Task Closure Data Reminder], t1.nvarchar21 as [Task Closure Data Reminder (3)], t1.ntext5 as [Link to Parent Request], t1.sql_variant2 as [Date Closed Plus 30], t1.nvarchar22 as [Close Auto Ent Rpoeting Log Items], t1.sql_variant3 as [Task Type] FROM UserData t1 WHERE t1.tp_ListId = &amp;#39;9A1C68ED-0EB1-4A93-813E-6531F3C0FE21&amp;#39; AND t1.tp_RowOrdinal = 0&lt;br /&gt;Msg 512, Level 16, State 1, Line 1&lt;br /&gt;Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &amp;lt;, &amp;lt;= , &amp;gt;, &amp;gt;= or when the subquery is used as an expression.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/3198365499922439506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/3198365499922439506'/><link rel='alternate' type='text/html' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html?showComment=1265141108294#c3198365499922439506' title=''/><author><name>David J. Kon</name><uri>http://www.blogger.com/profile/13867492484808507469</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html' ref='tag:blogger.com,1999:blog-1635568622827949164.post-6398656063312772604' source='http://www.blogger.com/feeds/1635568622827949164/posts/default/6398656063312772604' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-1635568622827949164.post-5355558622005698327</id><published>2010-02-03T02:18:16.208+11:00</published><updated>2010-02-03T02:18:16.208+11:00</updated><title type='text'>This is great! My only issue is it still does not ...</title><content type='html'>This is great! My only issue is it still does not work for lists with a large number of columns. I changed @sql to MAX, but I still get:&lt;br /&gt; XML parsing: line 1, character 5741, end tag does not match start tag&lt;br /&gt;&lt;br /&gt;This is much appreciated and could solve a lot of my issues. - Thanks</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/5355558622005698327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/5355558622005698327'/><link rel='alternate' type='text/html' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html?showComment=1265123896208#c5355558622005698327' title=''/><author><name>David J. Kon</name><uri>http://www.blogger.com/profile/13867492484808507469</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html' ref='tag:blogger.com,1999:blog-1635568622827949164.post-6398656063312772604' source='http://www.blogger.com/feeds/1635568622827949164/posts/default/6398656063312772604' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-1635568622827949164.post-8657894822645218594</id><published>2009-12-21T09:54:51.424+11:00</published><updated>2009-12-21T09:54:51.424+11:00</updated><title type='text'>MC Burley: Glad you liked it and commented; your r...</title><content type='html'>MC Burley: Glad you liked it and commented; your right... the 8000 char limit was my miscalculation based on SQL2000. With SQL +2005 when data in a MAX data type exceeds 8 KB, an over-flow page is used. So your list metadata can be up to 2GB, in effect no limit. I&amp;#39;ve removed the limitation from the article.&lt;br /&gt;The query (@sql) length is still 8000 chars, so if you have too many columns change this to a MAX.&lt;br /&gt;&lt;br /&gt;Merry Christmas.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/8657894822645218594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/8657894822645218594'/><link rel='alternate' type='text/html' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html?showComment=1261349691424#c8657894822645218594' title=''/><author><name>Ray Proffitt</name><uri>http://www.blogger.com/profile/15949105136667510991</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='10484134206468661863'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html' ref='tag:blogger.com,1999:blog-1635568622827949164.post-6398656063312772604' source='http://www.blogger.com/feeds/1635568622827949164/posts/default/6398656063312772604' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-1635568622827949164.post-5890446003225109860</id><published>2009-12-19T06:29:18.281+11:00</published><updated>2009-12-19T06:29:18.281+11:00</updated><title type='text'>You made my day with this one. Not sure I understa...</title><content type='html'>You made my day with this one. Not sure I understand the 8000 char limitation? I have a form library for InfoPath with 70 float columns promoted so far. Used your code to get the rowordinal in order to match the column names. I have about 50 more columns to add. Question: Running len(cast((tp_Fields ) as varchar(max)) returns 23460. How big can tp_Fields get before this breaks?&lt;br /&gt;Thanks for a great post.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/5890446003225109860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1635568622827949164/6398656063312772604/comments/default/5890446003225109860'/><link rel='alternate' type='text/html' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html?showComment=1261164558281#c5890446003225109860' title=''/><author><name>MC Burley</name><uri>http://www.blogger.com/profile/01254710558854007546</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ray1.net/2009/11/sharepoint-list-in-sql.html' ref='tag:blogger.com,1999:blog-1635568622827949164.post-6398656063312772604' source='http://www.blogger.com/feeds/1635568622827949164/posts/default/6398656063312772604' type='text/html'/></entry></feed>