Friday, February 24, 2012

Creating multilple tables at once

I had a SQL db that i copied all the tables into excel and it generated the quereies in order to create those tables....Is there anyway i could excute all those table creations at once or would it be easier to just write an application that does that for me?i am a little confused on what you are asking. That said if you have generated several CREATE TABLE scripts and your question here is can you compile them all into one big script and execute it to recreate all the tables at once, the answer is YES you can.|||How i do it is I open the Query ananlyzer and input the CREATE TABLE query I see it say the command has excuted succesfully but when does the actual table show up in the SQL server? does it have automatically or do i need to do some eles to actually create the table? How would i go about creating the create table script?|||

since you are using the term "Query Analyzer" I will presume that you are using SQL 2000...

In Query Analyzer you need to display the object explorer. If memory servesI think it was View/Object Explorer but regardless its in the main menu somewhere. Once you have object explorer displayed explore down to an individual table (you may be able to select multiple again its been a while) and select Tasks/Generate Script. Also in Enterprise Mgr. I believe you can perform the equivilent in Enterprise Mgr. (but i seem to recall thoughts that I couldnt so dunno for sure on that). Overall its a VERY EASY PROCESS.

Then open up Query Analyzer, select open file/query, browse to the .sql file you created previously and a new query window with the script's contents will be shown. Hit ctrl & F5 to syntax check it (just a habit of mine personally) and then hit F5 again to execute it. Now via Enterprsie Mgr. and Query Analyzer Object Explorer you should see your new tables. You can interact with the new tables via TSQL Queries or via the GUI in Enterprise Mgr.

Derek

No comments:

Post a Comment