Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array in T-SQL

Status
Not open for further replies.

Ken

IS-IT--Management
Jul 13, 2005
68
CA
Hi,

I am trying to get list of unique values from each column with number of records.

Code:
E.g. A table with 10 columns, then will be writing 10 times 
     to get unique values and number of records  as    
Select distinct field1, count(field1) from table1 group by field1

Is it possible to do in sp/tsql, then how ?
1) list all columns of a table in an array,
2) run select statement on each field from array
3) store result in a temporary table as tmpTable with field Col_Name, Col_Value, RecordCount.


Any ideas please on stored procedure or TSQL

Cheers,

Ken





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top