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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

issues with fn_listextendedproperty...

Status
Not open for further replies.

sensoukami

Technical User
Feb 25, 2003
19
0
0
CA
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:

------------------------------
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top