HELP! HOWTO Create new tables from a sql text file

  • Hello!

    I would like this to happen:

    I create a new database. In the database, I would like to create new tables

    and SP from a file.

    How can I do this? Are there any easier way of doing this? Could anyone

    guide me to open the file. Do I put the information inside a StringList, and

    use this to create the tables? Help!

    --

    - Lars

    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • Do you mean you have a file containing all DDL statements and you're looking for a way to execute this file?

    If so, open it with Query Analyzer, point to the right db, and hit F5 to run your statements

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Well that's not the issue here. How can I do this in code? Not in EM or QA, but in my application.

    I createt the sql file in EM(Enterprise Manager) when selected script a database.

    I was thinking of opening this file in my application and run the result in my application. Now I have all information inside the registry - but I don't think that's very good.

    - Lars

    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • What about using isql or osql utilities that come with SQL Server?

    They are explained in BOL

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Can I distribute the isql application?

    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • I don't know, but I thought you're developing an SQL Server application. In this case your client needs a license of SQL Server anyway. And so he should have both utilities.

    Btw, can you delete the other post on the same topic?

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • yes! what a fool!

    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • quote:


    Btw, can you delete the other post on the same topic?


    Sorry - but how do I delete it?

    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • you should see a trash can icon above the post.

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • I receive an error.

    Msg 170, Level 15, State1, Server LTG_ARBST, Line 1

    Line 1: Incorrect syntax near ' '.

    I can run this script in QA, but not in isql.

    Here is the code:

    isql /s(LTG_ARBST) /E /dLars /i c:\SQLTEST.SQL /n

    And here is the sqltest.sql

     if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tr_i_AUDIT_ARCHIVE_TABLE]') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
    
    drop trigger [dbo].[tr_i_AUDIT_ARCHIVE_TABLE]

    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.


    -Lars

    Please only reply to this newsgroup. All mails would be bounced back.

  • Try Osql


    * Noel

Viewing 11 posts - 1 through 10 (of 10 total)

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