Creating a new database with limits using SMO

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robinson

    #1

    Creating a new database with limits using SMO

    Hi,

    Using SMO (VB.NET), I'm creating a new database as shown below. I would
    like to change the growth size of the database (to 10%, it's defaulting to
    1mb at the moment) and also to set the maximum size I will allow it to grow
    to, to 10mb (for testing purposes). How can I do this on the SMO interface?

    Thanks for any tips,


    Robin




    theServer = New Server(Source.S erver)

    Dim theDatabase As New Database(theSer ver , newCatalog)

    theDatabase.Col lation = "SQL_Latin1_Gen eral_CP1_CI_AS"
    theDatabase.Com patibilityLevel = CompatibilityLe vel.Version90
    theDatabase.IsF ullTextEnabled = False

    theDatabase.Dat abaseOptions.An siNullDefault = False
    theDatabase.Dat abaseOptions.An siNullsEnabled = False
    theDatabase.Dat abaseOptions.An siPaddingEnable d = False
    theDatabase.Dat abaseOptions.An siWarningsEnabl ed = False
    theDatabase.Dat abaseOptions.Ar ithmeticAbortEn abled = False
    theDatabase.Dat abaseOptions.Au toClose = True
    theDatabase.Dat abaseOptions.Au toCreateStatist ics = True
    theDatabase.Dat abaseOptions.Au toShrink = True
    theDatabase.Dat abaseOptions.Au toUpdateStatist ics = True
    theDatabase.Dat abaseOptions.Cl oseCursorsOnCom mitEnabled = False
    theDatabase.Dat abaseOptions.Lo calCursorsDefau lt = False
    theDatabase.Dat abaseOptions.Co ncatenateNullYi eldsNull = False
    theDatabase.Dat abaseOptions.Nu mericRoundAbort Enabled = False
    theDatabase.Dat abaseOptions.Qu otedIdentifiers Enabled = False
    theDatabase.Dat abaseOptions.Re cursiveTriggers Enabled = False
    theDatabase.Dat abaseOptions.Br okerEnabled = True
    theDatabase.Dat abaseOptions.Au toUpdateStatist icsAsync = False
    theDatabase.Dat abaseOptions.Da teCorrelationOp timization = False
    theDatabase.Dat abaseOptions.Tr ustworthy = False
    theDatabase.Dat abaseOptions.Is Parameterizatio nForced = False
    theDatabase.Dat abaseOptions.Re adOnly = False
    theDatabase.Dat abaseOptions.Re coveryModel = RecoveryModel.S imple
    theDatabase.Dat abaseOptions.Us erAccess = DatabaseUserAcc ess.Multiple
    theDatabase.Dat abaseOptions.Pa geVerify = PageVerify.Torn PageDetection
    theDatabase.Dat abaseOptions.Da tabaseOwnership Chaining = False

    theDatabase.Cre ate(False)


  • Tom Moreau

    #2
    Re: Creating a new database with limits using SMO

    You manage file growth by using the DataFile objects:

    http://msdn2.microsoft.com/de-de/library/ms162176.aspx

    Set the Growth property:

    http://msdn2.microsoft.com/zh-tw/lib...le.growth.aspx

    --
    Tom

    ----------------------------------------------------
    Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
    SQL Server MVP
    Toronto, ON Canada
    ..
    "Robinson" <toomuchspamhas passed@myinboxt oomuchtoooften. comwrote in
    message news:ehssuc$3k6 $1$8300dec7@new s.demon.co.uk.. .
    Hi,

    Using SMO (VB.NET), I'm creating a new database as shown below. I would
    like to change the growth size of the database (to 10%, it's defaulting to
    1mb at the moment) and also to set the maximum size I will allow it to grow
    to, to 10mb (for testing purposes). How can I do this on the SMO interface?

    Thanks for any tips,


    Robin




    theServer = New Server(Source.S erver)

    Dim theDatabase As New Database(theSer ver , newCatalog)

    theDatabase.Col lation = "SQL_Latin1_Gen eral_CP1_CI_AS"
    theDatabase.Com patibilityLevel = CompatibilityLe vel.Version90
    theDatabase.IsF ullTextEnabled = False

    theDatabase.Dat abaseOptions.An siNullDefault = False
    theDatabase.Dat abaseOptions.An siNullsEnabled = False
    theDatabase.Dat abaseOptions.An siPaddingEnable d = False
    theDatabase.Dat abaseOptions.An siWarningsEnabl ed = False
    theDatabase.Dat abaseOptions.Ar ithmeticAbortEn abled = False
    theDatabase.Dat abaseOptions.Au toClose = True
    theDatabase.Dat abaseOptions.Au toCreateStatist ics = True
    theDatabase.Dat abaseOptions.Au toShrink = True
    theDatabase.Dat abaseOptions.Au toUpdateStatist ics = True
    theDatabase.Dat abaseOptions.Cl oseCursorsOnCom mitEnabled = False
    theDatabase.Dat abaseOptions.Lo calCursorsDefau lt = False
    theDatabase.Dat abaseOptions.Co ncatenateNullYi eldsNull = False
    theDatabase.Dat abaseOptions.Nu mericRoundAbort Enabled = False
    theDatabase.Dat abaseOptions.Qu otedIdentifiers Enabled = False
    theDatabase.Dat abaseOptions.Re cursiveTriggers Enabled = False
    theDatabase.Dat abaseOptions.Br okerEnabled = True
    theDatabase.Dat abaseOptions.Au toUpdateStatist icsAsync = False
    theDatabase.Dat abaseOptions.Da teCorrelationOp timization = False
    theDatabase.Dat abaseOptions.Tr ustworthy = False
    theDatabase.Dat abaseOptions.Is Parameterizatio nForced = False
    theDatabase.Dat abaseOptions.Re adOnly = False
    theDatabase.Dat abaseOptions.Re coveryModel = RecoveryModel.S imple
    theDatabase.Dat abaseOptions.Us erAccess = DatabaseUserAcc ess.Multiple
    theDatabase.Dat abaseOptions.Pa geVerify = PageVerify.Torn PageDetection
    theDatabase.Dat abaseOptions.Da tabaseOwnership Chaining = False

    theDatabase.Cre ate(False)


    Comment

    • Robinson

      #3
      Re: Creating a new database with limits using SMO


      "Tom Moreau" <tom@dont.spam. me.cips.cawrote in message
      news:eTIRQJc%23 GHA.4740@TK2MSF TNGP03.phx.gbl. ..
      You manage file growth by using the DataFile objects:
      >
      http://msdn2.microsoft.com/de-de/library/ms162176.aspx
      >
      Set the Growth property:
      >
      http://msdn2.microsoft.com/zh-tw/lib...le.growth.aspx
      >
      Ok I see that Tom. I'm going to stick with the defaults and then modify
      after database creation. That way I don't have to get my hands dirty adding
      filegroups and playing about with stuff I don't understand ;).

      Another thing about SQL Express if I may ask, if I specify the filegroup to
      grow, say, 10%, will it grow to the 4Gb limit or fail because 10% of 3.9Gb
      would take it over the 4Gb limit? Is the limit only for file space actually
      committed in tables?

      Thanks


      Robin


      Comment

      • Tom Moreau

        #4
        Re: Creating a new database with limits using SMO

        I'm not sure what would happen in the case of SQL Express. The limit is not
        for space actually used within the file. It is the limit for the file
        itself. Thus, you can have a 4GB file and be using only 10MB of it.

        --
        Tom

        ----------------------------------------------------
        Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
        SQL Server MVP
        Toronto, ON Canada

        "Robinson" <toomuchspamhas passed@myinboxt oomuchtoooften. comwrote in
        message news:eht6bc$drc $1$8300dec7@new s.demon.co.uk.. .

        "Tom Moreau" <tom@dont.spam. me.cips.cawrote in message
        news:eTIRQJc%23 GHA.4740@TK2MSF TNGP03.phx.gbl. ..
        You manage file growth by using the DataFile objects:
        >
        http://msdn2.microsoft.com/de-de/library/ms162176.aspx
        >
        Set the Growth property:
        >
        http://msdn2.microsoft.com/zh-tw/lib...le.growth.aspx
        >
        Ok I see that Tom. I'm going to stick with the defaults and then modify
        after database creation. That way I don't have to get my hands dirty adding
        filegroups and playing about with stuff I don't understand ;).

        Another thing about SQL Express if I may ask, if I specify the filegroup to
        grow, say, 10%, will it grow to the 4Gb limit or fail because 10% of 3.9Gb
        would take it over the 4Gb limit? Is the limit only for file space actually
        committed in tables?

        Thanks


        Robin



        Comment

        Working...