sensoukami
Technical User
Hello,
I want to use the fn_listextenededproperty. The problem is, I want to run the function from a storedproc in Database 'A', but I want to get the information on the properties from Database 'B'. Unfortunately, I have been unable to succeed.
The full stored procedure is this:
------------------------------
-----------------------------------
Basically, I pass in the table name, and bring back the metadata for the table. I can run this from within a given database to bring back info for a table in that database, but as I said, I want to run it in one DB and bring back info from another. Is this possible? Is there a different/better way?
Thanks in advance,
John
I want to use the fn_listextenededproperty. The problem is, I want to run the function from a storedproc in Database 'A', but I want to get the information on the properties from Database 'B'. Unfortunately, I have been unable to succeed.
The full stored procedure is this:
------------------------------
Code:
CREATE PROCEDURE [spGetTableMetaData]
@tblname as varchar(20)
AS
CREATE TABLE #TempTable
(
objName varchar(50),
[value] varchar(1000)
)
INSERT INTO #TempTable( objname, [value]) SELECT ISNULL(CONVERT(varchar(100),objname),'error'), ISNULL(CONVERT(varchar(100),[value]),'Description Null') FROM ::fn_listextendedproperty(null,'user','dbo','table
',@tblname,'column',default) ;
SELECT T.TABLE_NAME AS [Table],
C.CHARACTER_MAXIMUM_LENGTH AS [Length], C.COLUMN_NAME AS [Column], C.IS_NULLABLE AS [AllowNulls], C.DATA_TYPE AS Type,
D.value AS [Description]
FROM INFORMATION_SCHEMA.Tables T
INNER JOIN INFORMATION_SCHEMA.Columns C
ON T.TABLE_NAME = C.TABLE_NAME
INNER JOIN #TempTable D
on C.COLUMN_NAME = D.objname
WHERE (T.TABLE_NAME LIKE @tblname)
ORDER BY T.TABLE_NAME, C.ORDINAL_POSITION
Drop table #TempTable
GO
Basically, I pass in the table name, and bring back the metadata for the table. I can run this from within a given database to bring back info for a table in that database, but as I said, I want to run it in one DB and bring back info from another. Is this possible? Is there a different/better way?
Thanks in advance,
John