Create Table Default Data Type Length

  • Hello Everyone

    I have a rather odd kind of question that I cannot seem to find an answer in the BOL.

    When, for example, there is a normal create table statement, with normal columns and data types being declared. When the data type has not length set, what will be the default length?

    CREATE TABLE dbo.TableName

    PersonSex char

    Since there is not a length set on the char data type. What would be the default length? Would SQL user the Minimum length such as 1, or would SQL use the Maximum length?

    Thank you in advance for all your comments, suggestions and assistance

    Andrew SQLDBA

  • the default length is 1.

    when you use cast or convert, the default length is 30, but for column definitions, it's a single character.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks Lowell

    After posting, I went back to the BOL, and read it. It was like that one sentence was glaring out at me. 🙂

    Thanks again

    Andrew

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply