Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


extended property for all columns of all tables


extended property for all columns of all tables

Author
Message
enrique.prados
enrique.prados
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 12
Hi everybody, misters

I create extended properties asociated to columns of tables:

EXEC sp_addextendedproperty
@name = N'TablaMaestra', @value = 'Descripcion',
@level0type = N'Schema', @level0name = dbo,
@level1type = N'Table', @level1name = tabla1,
@level2type = N'Column', @level2name = Descripcion;
GO

I get the value of extended property of columns of the "tabla1" table:

select objtype,objname,[name],[value]
from fn_listextendedproperty (null,'Schema','dbo','TABLE','tabla1','COLUMN',null)

How can I get extended properties of all columns of all tables ?

Greetings, regards, thanks in advance
Phil Factor
Phil Factor
Right there with Babe
Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)

Group: General Forum Members
Points: 745 Visits: 2937
SELECT  SCHEMA_NAME(tbl.schema_id) AS [Table_Schema],
        
tbl.name AS [Table_Name],
        
clmns.name AS [Column_Name],
        
p.name AS [Name],
        
CAST(p.value AS SQL_VARIANT) AS [Value]
FROM    sys.tables AS tbl
        
INNER JOIN sys.all_columns AS clmns ON clmns.OBJECT_ID=tbl.OBJECT_ID
        
INNER JOIN sys.extended_properties AS p ON p.major_id=clmns.OBJECT_ID
                                                  
AND p.minor_id=clmns.column_id
                                                  
AND p.class=1
ORDER BY [Table_Schema] ASC,
        
[Table_Name] ASC,
        
[Column_ID] ASC,
        
[Name] ASC




Best wishes,

Phil Factor
Simple Talk
JKSQL
JKSQL
SSC-Addicted
SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)

Group: General Forum Members
Points: 460 Visits: 683
That was great helped me out so I can export properties and I added column definitions. Currently I am putting my descriptions in just saying MS_Description. Should I be using something more appropriate. Do you break apart your descriptions into more logical formats? If so can you give me an example so I do not stumble on this in a year?
Phil Factor
Phil Factor
Right there with Babe
Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)Right there with Babe (745 reputation)

Group: General Forum Members
Points: 745 Visits: 2937

Yes. I put everything in MS_Description because this is the only thing that is accessible to SSMS. I then put a YAML structure into the string so I can do lists and sections.


The section between the /** **/ is placed into, or updated to, the extended property by an automated process.



IF OBJECT_ID(N'IsSpace') IS NOT NULL
  
DROP FUNCTION IsSpace
GO
CREATE FUNCTION dbo.[IsSpace] (@string VARCHAR(MAX))  
/**
summary:   >
                      IsSpace string Function Returns Non-Zero if all characters
                      in s are whitespace characters, 0 otherwise.
example:
     - code:    Select dbo.IsSpace('how many times must i tell you')
     - code:    Select dbo.IsSpace(' <>[]{}"!@#$%9  Wink))))))')
     - code:    Select dbo.IsSpace(' ????/>.<,')*/
returns:     integer:  1  IF whitespace, otherwise 0
**/
RETURNS INT
AS BEGIN
      RETURN
CASE WHEN PATINDEX(
              
'%[A-Za-z0-9-]%', @string  COLLATE Latin1_General_CS_AI
                                
) > 0 THEN 0
                  
ELSE 1
            
END
   END
GO



Best wishes,

Phil Factor
Simple Talk
JKSQL
JKSQL
SSC-Addicted
SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)SSC-Addicted (460 reputation)

Group: General Forum Members
Points: 460 Visits: 683
You lost me on that last post. I understand what yaml is and I can see if being beneficial. I am lost on how you are using it though. Is this for outputting the data into yaml? Currently I have two ways I output one is sharepoint compatible (excel) and the other I use codesmith to put it in html docs so i have define the whole DB if needed. Would Yaml some how replace those?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search