Results 1 to 15 of 15

Thread: Database - schema creation and updates

  1. #1

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Database - schema creation and updates

    Hi guys...

    I would like some comments about how do you manage the creation and updates of a database (SQL Server) schema in a Vb.net application...

    do you ask your customers to load scripts in SQL Server Management Studio (or query analiser)... or dou you make your own application to perform this task?

    and what about versions... does your applications validate database schemas versions? and how do you manage to do that?

    im searching for days for this matter... all i find is information about batch files calling osql... i dont consider this a good and professional solution...

    thx in advance...

  2. #2

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Database - schema creation and updates

    ...

    in my previous applications i left this task to database administrators... but 99% of my customers are small companies, and dont have database administrators...

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Database - schema creation and updates

    Yes, they check the db schema and apply alter table statements etc to update a db to a new version of an app. I never rely upon a client to run anything other then an executable update/service pack or something because they usually are not tech savy or if they do something wrong it takes forever to walk them through any type of analysis.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Database - schema creation and updates

    well... my databases have a version number...

    what i am trying to do is provide the customer the sql script with a xml config file, with version/patch numbers, release dates, and some tech information... the application would have somekind of database admin section, that would check database version, impose the db update and enable the user to select the xml config file... after that would validate and execute the sql script against the database...

    my problem is just i cant find how to execute a sql script generated by sql manager console without errors...

    and i dont want to embed sql statements in code...

  5. #5

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Database - schema creation and updates

    how do you manage to run that update statements?

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Database - schema creation and updates

    Have you looked into the DTSRUN command line utility?

    Or even using OSQL in a .BAT file to run a .SQL text script?

    Personally - we manage our updates to customer databases - they pay for annual maintenance and expect us to handle that end of the DBA work.

    We even have full DBA contracts with some customers so that we are responsible for backups and disk space and whatever else a SQL box needs to run smooth.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Database - schema creation and updates

    Quote Originally Posted by szlamany
    Have you looked into the DTSRUN command line utility?

    Or even using OSQL in a .BAT file to run a .SQL text script?

    Personally - we manage our updates to customer databases - they pay for annual maintenance and expect us to handle that end of the DBA work.

    We even have full DBA contracts with some customers so that we are responsible for backups and disk space and whatever else a SQL box needs to run smooth.
    DTSRUN... let me take a look at that...

    osql and bat files??? as i said...dont consider this a good and professional solution

    i cant manage myself customer for db updates...

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Database - schema creation and updates

    The osql utility is the command line version of Query Analyzer and it does take arguments and returns values too.

    My updater is basic. It just verifies the tables and fields exist and if not executes the alter query to update the table to the current version.
    [/color]
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Database - schema creation and updates

    Quote Originally Posted by RobDog888
    The osql utility is the command line version of Query Analyzer and it does take arguments and returns values too.

    My updater is basic. It just verifies the tables and fields exist and if not executes the alter query to update the table to the current version.
    [/color]
    sql embebbed in your application?... i want to make a tool so i dont have to create new versions only to upadte db...

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Database - schema creation and updates

    Then you can have it read it the xml file that you were talking about.
    Like I was saying, mine is very basic as I didnt have time to make it dynamic or fancy
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Database - schema creation and updates

    and what bout first time creation... in a new customer... do it yourself?

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Database - schema creation and updates

    If ts first time creation and not using .NET 2005 then it would also be CREATE DATABASE and GRANT statements to create the db and assign permissions to a Windows Security group. Then the end user can manually add/remove their windows users to/from that group as a way of controlling access to the program running.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Database - schema creation and updates

    Quote Originally Posted by zuperman
    and what bout first time creation... in a new customer... do it yourself?
    There are so many issues related to this...

    I've got a customer who would not give me admin rights to the SQL server. This meant they would take only a .BAK that they would RESTORE onto the server or the choice I took - they created 5 empty DB's and I used scripts myself to create objects (tables, sprocs and what not).

    btw - when we used OSQL in a nightly process 5 years ago to keep a SQL box sync'd with a mainframe we developed a "review" program that would "read" the OSQL output log and look for errors.

    What is so unprofessional about OSQL in your opinion?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  14. #14

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: Database - schema creation and updates

    Quote Originally Posted by szlamany
    What is so unprofessional about OSQL in your opinion?
    ...the most annoyng thing is that i cant catch errors to the user...unlike you, i havent figured out to do that

    if i manage to do that i think it would be a good solution... can you explain how you do it... (dont need code, only the main steps)...

    thx...

  15. #15
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Database - schema creation and updates

    We got to know what the log file produced by OSQL would look like and simply opened it with a little VB program and read through it looking for errors.

    You could distribute your .SQL script along with a .ExpectedLogFile with it - and after you run OSQL you compare the .LOG output to the .ExpectedLogFile with a little VB program - looking for errors.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width