So, at this particular time, I cannot find a way to include certain column names in a statement that I have been using.
Here is the code:
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.rows),
[Columnname] = c.name
FROM
sysobjects so,
sysindexes si,
syscolumns c
WHERE
so.xtype = 'U'
AND
si.id = OBJECT_ID(so.name)
GROUP BY
so.name
ORDER BY
2 DESC
this is the original code without the syscloumns:
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.rows)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U'
AND
si.id = OBJECT_ID(so.name)
GROUP BY
so.name
ORDER BY
2 desc
I figure that I could use something like C.column, but it keeps giving me this error:
Column 'sysobjects.name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
All I am trying to do is get row count per table and have certain columns like date of employment and products sold. but I just can't seem to use what I already have to include those columns.
What I have tried:
tried to add a syscolumns into the list but as stated above I keep getting an error.