none
sql server 2008 columns RRS feed

  • Question

  • I am setting up an sql server 2008 r2 database with the associated tables, views and stored procedures for one main customer only. I receive files from this customer daily. My company says that I just need to change as they change.

    Basically I am trying to decide what to do with the size of a transaction code field. Up until last week, the field was a number that was a size of 3. For future expansion, I was thinking of making the field a numeric field that was size of 10.

    As of last week, I started to receive values that was 1 alpha character and 2 numbers.

    Thus I am trying to decide how to define the field size. I am thinking of using varchar(10) over char(10) or some smaller sized field? What size of field would you use and why?


    Wednesday, May 23, 2012 12:01 PM

Answers

  • Given that you don't really know what the transaction code will be in the future, but if you can ensure it will be smaller than 10 characters then varchar(10) is a good option.

    As you mentioned that the data might be only 3 characters, so to use char(10) will waste 7 bytes.

    Wednesday, May 23, 2012 12:53 PM

All replies

  • SSRS is a service which creates ReportServer and ReportServerTempDB databases... Do you have problems to create a report? Can you explain a little bit what  you are trying to achieve.


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

    Wednesday, May 23, 2012 12:13 PM
    Answerer
  • Given that you don't really know what the transaction code will be in the future, but if you can ensure it will be smaller than 10 characters then varchar(10) is a good option.

    As you mentioned that the data might be only 3 characters, so to use char(10) will waste 7 bytes.

    Wednesday, May 23, 2012 12:53 PM
  • Hi,

    If you are trying to design a database where you may be loading data from an external source, it will good if you can get the data specification from the source side. 

    Regards
    Satheesh

    Wednesday, May 23, 2012 12:59 PM
  • The user gives me the data the way they want to. I have no option on what it will look like in the future.
    Wednesday, May 23, 2012 6:44 PM