Monday, March 19, 2012

getting results based on results.

Greetings:

I have the following query which will get the column name of the table I am trying to work on ..

· SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS Where TABLE_NAME = 'MyDataTable'

This query will give me the column name of “MyDataTable”. But I need to add some calculated field – i.e get the number of rows which are not null from “myDataTable” for a particular column.

I tried :

SELECT COLUMN_NAME,

myField = (Select Count(*) from myDataTable);

FROM INFORMATION_SCHEMA.COLUMNS Where TABLE_NAME = 'MyDataTable'

The above one gives me the total number of rows in the “myDataTable”

Anybody that have some kind of idea for a work around please help.

Thanks,

Yared,

I've moved this thread from Announcement area.
Good luck on your question,
-chris

No comments:

Post a Comment