﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server Newbies  / syscolumns / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 08:46:30 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: syscolumns</title><link>http://www.sqlservercentral.com/Forums/Topic630941-1291-1.aspx</link><description>Continued here - [url]http://www.sqlservercentral.com/Forums/Topic630987-169-1.aspx[/url]No more replies to this thread please.</description><pubDate>Tue, 06 Jan 2009 14:53:23 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: syscolumns</title><link>http://www.sqlservercentral.com/Forums/Topic630941-1291-1.aspx</link><description>apologies - just noticed it was the 2005 forum</description><pubDate>Tue, 06 Jan 2009 13:43:53 GMT</pubDate><dc:creator>:O)</dc:creator></item><item><title>RE: syscolumns</title><link>http://www.sqlservercentral.com/Forums/Topic630941-1291-1.aspx</link><description>Please post SQL 2000-related questions in the SQL 2000 forums. If you post in the 2005 forums, you're very likely to get 2005-specific solutions.The Information schema exists in 2000 as well, and looks the same as it does in 2005.</description><pubDate>Tue, 06 Jan 2009 13:42:15 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: syscolumns</title><link>http://www.sqlservercentral.com/Forums/Topic630941-1291-1.aspx</link><description>Sorry ALZDBA - I am only on sqlserver2000 !Liked the bike on yor profile pic !:cool:</description><pubDate>Tue, 06 Jan 2009 13:27:53 GMT</pubDate><dc:creator>:O)</dc:creator></item><item><title>RE: syscolumns</title><link>http://www.sqlservercentral.com/Forums/Topic630941-1291-1.aspx</link><description>Better would be to use the information schema views.Keep in mind that sql2005 only show object definitions you are granted to view.(view definition granted)Is this what you're looking for ?[code]SELECT CASE t1.[ORDINAL_POSITION] WHEN 1 THEN 'SELECT ' ELSE ' , ' end + ' count( distinct ['+ t1.[COLUMN_NAME] + '] ) as [Count_distinct_' + t1.[COLUMN_NAME] + '_' + CASE t1.[ORDINAL_POSITION] WHEN t2.[MAX_ORDINAL_POSITION] THEN ' from  [' + t1.[TABLE_SCHEMA] + '].[' +  t1.[TABLE_NAME] + '] ;' ELSE ' ' end FROM [INFORMATION_SCHEMA].[COLUMNS] t1 INNER JOIN ( SELECT [TABLE_NAME], [TABLE_SCHEMA], MAX([ORDINAL_POSITION]) AS MAX_ORDINAL_POSITION 	FROM [INFORMATION_SCHEMA].[COLUMNS]   GROUP BY [TABLE_NAME], [TABLE_SCHEMA] )t2ON t1.[TABLE_NAME] = t2.[TABLE_NAME]AND t1.[TABLE_SCHEMA] = t2.[TABLE_SCHEMA]WHERE t1.[TABLE_NAME] = 'mytable'ORDER BY t1.[TABLE_NAME], t1.[TABLE_SCHEMA], t1.[ORDINAL_POSITION][/code]</description><pubDate>Tue, 06 Jan 2009 13:22:52 GMT</pubDate><dc:creator>ALZDBA</dc:creator></item><item><title>syscolumns</title><link>http://www.sqlservercentral.com/Forums/Topic630941-1291-1.aspx</link><description>Folks,Say I have a table with columns, colA, colB, colC and colD and there are 20 rows in my table. I want to write a sort of dynamic script to show me a count of non-null columns.The result set would look something likecolA        5colB        20colC        10colD        1This example would show that each row had colb populated in each of the 20 rows.I know I could write a select that would generate some individual sql statements using syscolumns.name and syscolumns.id and I could then execute each of those statements but is there a way to do this more neatly ?</description><pubDate>Tue, 06 Jan 2009 13:09:07 GMT</pubDate><dc:creator>:O)</dc:creator></item></channel></rss>