 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQL Single Column Table</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/</link>
	<description></description>
	<lastBuildDate>Sat, 25 May 2013 00:24:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: SAffer</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110563</link>
		<dc:creator>SAffer</dc:creator>
		<pubDate>Tue, 28 Aug 2012 07:29:53 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110563</guid>
		<description><![CDATA[It looks like the PIVOT command is exactly what I am looking for.
&#160;
My view structure is based&#160;on what the Help&#160;for the PIVOT command suggests - a simpler way of creating summarised data rather than using a complex CASE command.
I&#039;m going to try this first -&#160;if I don&#039;t come right then I&#039;ll be back for futher assistance and explain in much more detail what I am trying to do - thanks for the feedback, I really appreciate it.&#160;]]></description>
		<content:encoded><![CDATA[<p>It looks like the PIVOT command is exactly what I am looking for.<br />
&nbsp;<br />
My view structure is based&nbsp;on what the Help&nbsp;for the PIVOT command suggests &#8211; a simpler way of creating summarised data rather than using a complex CASE command.<br />
I&#8217;m going to try this first -&nbsp;if I don&#8217;t come right then I&#8217;ll be back for futher assistance and explain in much more detail what I am trying to do &#8211; thanks for the feedback, I really appreciate it.&nbsp;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110549</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Mon, 27 Aug 2012 23:31:33 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110549</guid>
		<description><![CDATA[&lt;em&gt;&quot;You couldn’t even give the columns names.&quot;&lt;/em&gt;

That&#039;s why I mentioned the possibility to alias the column names with numbers when creating the view (I know, you still wouldn&#039;t know the number of columns, but if you knew, you would know how to call them), but as I mentioned before, I don&#039;t think I would want to have something like that.&#160;

I think the main problem is that we don&#039;t know te reasons why this table exists in the first place, and why &lt;a href=&quot;http://itknowledgeexchange.techtarget.com/profile/SAffer&quot; rel=&quot;nofollow&quot;&gt;SAffer&lt;/a&gt;&#160;wants to create such a view from it.]]></description>
		<content:encoded><![CDATA[<p><em>&#8220;You couldn’t even give the columns names.&#8221;</em></p>
<p>That&#8217;s why I mentioned the possibility to alias the column names with numbers when creating the view (I know, you still wouldn&#8217;t know the number of columns, but if you knew, you would know how to call them), but as I mentioned before, I don&#8217;t think I would want to have something like that.&nbsp;</p>
<p>I think the main problem is that we don&#8217;t know te reasons why this table exists in the first place, and why <a href="http://itknowledgeexchange.techtarget.com/profile/SAffer" rel="nofollow">SAffer</a>&nbsp;wants to create such a view from it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110545</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Mon, 27 Aug 2012 22:35:44 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110545</guid>
		<description><![CDATA[@carlosdl:
&#160;
Couldn&#039;t the view be created over a recursive CTE? The major problem would be that it would result in a single column with all of the values in a single string. But that would be the only way to handle such a view anyway.
&#160;
You couldn&#039;t do anything useful with a view that had an unknown number of columns. You couldn&#039;t do any WHERE or ORDER BY if you never knew that columns would be there. You couldn&#039;t even give the columns names.
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>@carlosdl:<br />
&nbsp;<br />
Couldn&#8217;t the view be created over a recursive CTE? The major problem would be that it would result in a single column with all of the values in a single string. But that would be the only way to handle such a view anyway.<br />
&nbsp;<br />
You couldn&#8217;t do anything useful with a view that had an unknown number of columns. You couldn&#8217;t do any WHERE or ORDER BY if you never knew that columns would be there. You couldn&#8217;t even give the columns names.<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110537</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Mon, 27 Aug 2012 18:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110537</guid>
		<description><![CDATA[Sorry, the editor created a mess with the formatting.]]></description>
		<content:encoded><![CDATA[<p>Sorry, the editor created a mess with the formatting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110536</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Mon, 27 Aug 2012 18:27:30 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110536</guid>
		<description><![CDATA[The PIVOT operator is usually what you would use to create cross tab queries, but&#160; I don&#039;t think doing it on single-column tables is its intended use.&#160;Comes to mind something like this, but you would still need to know the possible values before hand:SELECT * 
FROM (SELECT col1,col1 col2 FROM test1)
pivot
(
  MAX(col1)
  FOR col2 IN (&#039;AL1&#039;,&#039;AL2&#039;,&#039;AL3&#039;,&#039;AK01&#039;)
);&#160;You could alias the column names if necessary:
SELECT * 
FROM (SELECT col1,col1 col2 FROM test1)
pivot
(
  MAX(col1)
  FOR col2 IN (&#039;AL1&#039; AS &quot;1&quot;,&#039;AL2&#039; AS &quot;2&quot;,&#039;AL3&#039; AS &quot;3&quot;,&#039;AK01&#039; AS &quot;4&quot;)
);

But since you are asking for a way to create a view, I suppose you expect it to automatically change as you insert new rows into the table, which is not possible with this approach

You could write some code to generate this query dinamically based on the current data on the table, and put it in a trigger so the view is recreated every time a new row is inserted, but I&#039;m not sure I would like to do something like that (I&#039;m not sure I would have a table like that either...)]]></description>
		<content:encoded><![CDATA[<p>The PIVOT operator is usually what you would use to create cross tab queries, but&nbsp; I don&#8217;t think doing it on single-column tables is its intended use.&nbsp;Comes to mind something like this, but you would still need to know the possible values before hand:SELECT *<br />
FROM (SELECT col1,col1 col2 FROM test1)<br />
pivot<br />
(<br />
  MAX(col1)<br />
  FOR col2 IN (&#8216;AL1&#8242;,&#8217;AL2&#8242;,&#8217;AL3&#8242;,&#8217;AK01&#8242;)<br />
);&nbsp;You could alias the column names if necessary:<br />
SELECT *<br />
FROM (SELECT col1,col1 col2 FROM test1)<br />
pivot<br />
(<br />
  MAX(col1)<br />
  FOR col2 IN (&#8216;AL1&#8242; AS &#8220;1&#8243;,&#8217;AL2&#8242; AS &#8220;2&#8243;,&#8217;AL3&#8242; AS &#8220;3&#8243;,&#8217;AK01&#8242; AS &#8220;4&#8243;)<br />
);</p>
<p>But since you are asking for a way to create a view, I suppose you expect it to automatically change as you insert new rows into the table, which is not possible with this approach</p>
<p>You could write some code to generate this query dinamically based on the current data on the table, and put it in a trigger so the view is recreated every time a new row is inserted, but I&#8217;m not sure I would like to do something like that (I&#8217;m not sure I would have a table like that either&#8230;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SAffer</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110534</link>
		<dc:creator>SAffer</dc:creator>
		<pubDate>Mon, 27 Aug 2012 16:34:11 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110534</guid>
		<description><![CDATA[Hi Tom
It would most definately look like this e.g.
AL1
AL2
AL3
AK01
AK02&#160; etc. -&#160;the column being 4 alpha characters long and either 3 or&#160;4 characters used
to give AL1 &#160;AL2&#160; AL3 &#160;AK01 AK02 AL1 &#160;AL2&#160;&#160;BX01 BX01 etc.&#160;
I hope you can help - obviously the easiest would be a single command if there is one, otherwise a recurring structure without having to &#039;hard code&#039; each column&#160;with the CASE command
&#160;]]></description>
		<content:encoded><![CDATA[<p>Hi Tom<br />
It would most definately look like this e.g.<br />
AL1<br />
AL2<br />
AL3<br />
AK01<br />
AK02&nbsp; etc. -&nbsp;the column being 4 alpha characters long and either 3 or&nbsp;4 characters used<br />
to give AL1 &nbsp;AL2&nbsp; AL3 &nbsp;AK01 AK02 AL1 &nbsp;AL2&nbsp;&nbsp;BX01 BX01 etc.&nbsp;<br />
I hope you can help &#8211; obviously the easiest would be a single command if there is one, otherwise a recurring structure without having to &#8216;hard code&#8217; each column&nbsp;with the CASE command<br />
&nbsp;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomLiotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110509</link>
		<dc:creator>TomLiotta</dc:creator>
		<pubDate>Mon, 27 Aug 2012 07:16:51 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110509</guid>
		<description><![CDATA[Just to be sure, you have a table with single-column data:
&#160;
Abc
Defghi
Jklmn
&#160;
And you want a view that gives this result:
&#160;
Abc Defghi Jklmn
&#160;
Is that right?
&#160;
Tom]]></description>
		<content:encoded><![CDATA[<p>Just to be sure, you have a table with single-column data:<br />
&nbsp;<br />
Abc<br />
Defghi<br />
Jklmn<br />
&nbsp;<br />
And you want a view that gives this result:<br />
&nbsp;<br />
Abc Defghi Jklmn<br />
&nbsp;<br />
Is that right?<br />
&nbsp;<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SAffer</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110508</link>
		<dc:creator>SAffer</dc:creator>
		<pubDate>Mon, 27 Aug 2012 07:05:23 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110508</guid>
		<description><![CDATA[Hi Carlos
The tag got missmatched somehow - SQL Server 2005.]]></description>
		<content:encoded><![CDATA[<p>Hi Carlos<br />
The tag got missmatched somehow &#8211; SQL Server 2005.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110444</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Fri, 24 Aug 2012 19:00:32 +0000</pubDate>
		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-single-column-table/#comment-110444</guid>
		<description><![CDATA[What database platform (and version) are you using ?]]></description>
		<content:encoded><![CDATA[<p>What database platform (and version) are you using ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/8 queries in 0.029 seconds using memcached
Object Caching 381/382 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-25 03:33:03 -->