Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6687141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:15:12+00:00 2026-05-26T05:15:12+00:00

I’m trying to figure out a way to store metadata about a column without

  • 0

I’m trying to figure out a way to store metadata about a column without repeating myself.

I’m currently working on a generic dimension loading SSIS package that will handle all my dimensions. It currently does :

  1. Create a temporary table identical to the given table name in parameters (this is a generic stored procedure that receive the table name as parameter, and then do : select top 0 * into ##[INSERT ORIGINAL TABLE NAME HERE] from [INSERT ORIGINAL TABLE NAME HERE]).
  2. ==> Here we insert custom code for this particular dimension that will first query the data from a datasource and get my delta, then transform the data and finally loads it into my temporary table.
  3. Merge the temporary table into my original table with a T-SQL MERGE, taking care of type1 and type2 fields accordingly.

My problem right now is that I have to maintain a table with all the fields in it to store a metadata to tell my scripts if this particular field is type1 or type2… this is nonsense, I can get the same data (minus type1/type2) from sys.columns/sys.types.

I was ultimately thinking about renaming my fields to include their type in it, such as :
FirstName_T2, LastName_T2, Sex_T1 (well, I know this can be type2, let’s not fall into that debate here).

What do you guyz would do with that? My solution (using a table with that metadata) is currently in place and working, but it’s obvious that repeating myself from the systables to a custom table is nonsense, just for a simple type1/type2 info.

UPDATE: I also thought about creating user defined types like varchar => t1_varchar, t2_varchar, etc. This sounds like something a bit sluggy too…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:15:13+00:00Added an answer on May 26, 2026 at 5:15 am

    I know this is bad, but I will post an answer to my own question… Thanks to GBN for the help tho!

    I am now storing “flags” in the “description” field of my columns. I, for example, can store a flag this way : “TYPE_2_DATA”.

    Then, I use this query to get the flag back for each and every column :

    select columns.name as [column_name]
          ,types.name as [type_name]
          ,extended_properties.value as [column_flags]
      from sys.columns 
     inner join sys.types
             on columns.system_type_id = types.system_type_id
      left join sys.extended_properties
             on extended_properties.major_id = columns.object_id 
            and extended_properties.minor_id = columns.column_id  
            and extended_properties.name = 'MS_Description'
     where object_id = ( select id from sys.sysobjects where name = 'DimDivision' )
       and is_identity = 0
     order by column_id
    

    Now I can store metadata about columns without having to create a separate table. I use what’s already in place and I don’t repeat myself. I’m not sure this is the best possible solution yet, but it works and is far better than duplicating information.

    In the future, I will be able to use this field to store more metadata, where as : “TYPE_2_DATA|ANOTHER_FLAG|ETC|OH BOY!”.

    UPDATE :

    I now store the information in separate extended properties. You can manage extended properties using sp_addextendedproperty and sp_updateextendedproperty stored procedures. I have created a simple store procedure that help me to update those values regardless if they currently exist or not :

    create procedure [dbo].[UpdateSCDType]
        @tablename nvarchar(50),
        @fieldname nvarchar(50),
        @scdtype  char(1),
        @dbschema nvarchar(25) = 'dbo'
    as
    begin
    
        declare @already_exists int;
    
        if ( @scdtype = '1' or @scdtype = '2' )
        begin
    
             select @already_exists = count(1)
              from sys.columns 
             inner join sys.extended_properties 
                     on extended_properties.major_id = columns.object_id 
                    and extended_properties.minor_id = columns.column_id 
                    and extended_properties.name     = 'ScdType' 
             where object_id = (select sysobjects.id from sys.sysobjects where sysobjects.name = @tablename) 
               and columns.name = @fieldname
    
            if ( @already_exists = 0 )
            begin
    
                exec sys.sp_addextendedproperty 
                     @name       = N'Scd_Type', 
                     @value      = @scdtype, 
                     @level0type = N'SCHEMA',
                     @level0name = @dbschema,
                     @level1type = N'TABLE',
                     @level1name = @tablename,
                     @level2type = N'COLUMN',
                     @level2name = @fieldname
    
            end
            else
            begin
    
                exec sys.sp_updateextendedproperty 
                     @name       = N'Scd_Type', 
                     @value      = @scdtype, 
                     @level0type = N'SCHEMA',
                     @level0name = @dbschema,
                     @level1type = N'TABLE',
                     @level1name = @tablename,
                     @level2type = N'COLUMN',
                     @level2name = @fieldname
    
            end
    
        end
    
    end
    

    Thanks again

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.