D
David Thielen
Hi;
We are trying to get the metadata description field for a table, view,
& column. Is there any way to get this for a table/view?
And for a column this is what we are using - but it's very slow. Is
there a faster way:
Version 8:
cmd.CommandText = "SELECT COLUMN_NAME, sysproperties.[value] FROM
INFORMATION_SCHEMA.COLUMNS LEFT OUTER JOIN " +
"sysproperties ON sysproperties.id =
OBJECT_ID(INFORMATION_SCHEMA.COLUMNS.TABLE_SCHEMA + '.' + " +
"INFORMATION_SCHEMA.COLUMNS.TABLE_NAME) AND
sysproperties.smallid = INFORMATION_SCHEMA.COLUMNS.ORDINAL_POSITION "
+
"AND sysproperties.name = 'MS_Description' WHERE
(OBJECTPROPERTY(OBJECT_ID(INFORMATION_SCHEMA.COLUMNS.TABLE_SCHEMA " +
"+ '.' + INFORMATION_SCHEMA.COLUMNS.TABLE_NAME),
'IsMsShipped') = 0) AND (TABLE_NAME = @p1)";
cmd.Parameters.Add(MakeParam("@p1", table));
Version 9+:
cmd.CommandText = "SELECT c.name AS [Column Name], ex.value AS
Description FROM sys.columns AS c INNER JOIN " +
"sys.extended_properties AS ex ON ex.major_id = c.object_id
AND ex.minor_id = c.column_id AND ex.name = " +
"'MS_Description' WHERE (OBJECTPROPERTY(c.object_id,
'IsMsShipped') = 0) AND (OBJECT_NAME(c.object_id) = @p1)";
cmd.Parameters.Add(MakeParam("@p1", table));
??? - thanks - dave
david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
Cubicle Wars - http://www.windwardreports.com/film.htm
We are trying to get the metadata description field for a table, view,
& column. Is there any way to get this for a table/view?
And for a column this is what we are using - but it's very slow. Is
there a faster way:
Version 8:
cmd.CommandText = "SELECT COLUMN_NAME, sysproperties.[value] FROM
INFORMATION_SCHEMA.COLUMNS LEFT OUTER JOIN " +
"sysproperties ON sysproperties.id =
OBJECT_ID(INFORMATION_SCHEMA.COLUMNS.TABLE_SCHEMA + '.' + " +
"INFORMATION_SCHEMA.COLUMNS.TABLE_NAME) AND
sysproperties.smallid = INFORMATION_SCHEMA.COLUMNS.ORDINAL_POSITION "
+
"AND sysproperties.name = 'MS_Description' WHERE
(OBJECTPROPERTY(OBJECT_ID(INFORMATION_SCHEMA.COLUMNS.TABLE_SCHEMA " +
"+ '.' + INFORMATION_SCHEMA.COLUMNS.TABLE_NAME),
'IsMsShipped') = 0) AND (TABLE_NAME = @p1)";
cmd.Parameters.Add(MakeParam("@p1", table));
Version 9+:
cmd.CommandText = "SELECT c.name AS [Column Name], ex.value AS
Description FROM sys.columns AS c INNER JOIN " +
"sys.extended_properties AS ex ON ex.major_id = c.object_id
AND ex.minor_id = c.column_id AND ex.name = " +
"'MS_Description' WHERE (OBJECTPROPERTY(c.object_id,
'IsMsShipped') = 0) AND (OBJECT_NAME(c.object_id) = @p1)";
cmd.Parameters.Add(MakeParam("@p1", table));
??? - thanks - dave
david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
Cubicle Wars - http://www.windwardreports.com/film.htm