Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Fields to every new table

Status
Not open for further replies.

storm75m

Programmer
Apr 18, 2001
81
US
Is there an easy way to have some fields be in every new table that I create? I would like every table in my database to have the same 5 fields (GenUsr, GenDate, ModUsr, ModDate, Spare1), but I don't want to have to copy and paste them from other tables. Just trying to find out if there is an easy way to do this... thanks.
 
create one table as you want above then script it and use that as your start point for each create table script

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
I suppose the easiest way would be to create a Create Table template in QA which contains these five fields and any defaults that you want them to have. Then every time you create a table, use the templete, add the additional fiedls and the table name then run it. Templates are relly cool for this type of thing. I also have one to create stored procedure that need transaction porcessing which contains the transaction and error processing code and all I have to do is add the insert, update and/or delete statments and name the sp. Has saved me tons of time.

Now how do you do this and use the templates.

First write the code you want to reuse, then go tothe file/Save As menu and choose templateSQL files. Make sure to create any comments that will help you rememebr what you want filled in where. Once it is saved, you should see it on the object browser on the templates tab.

To use, right click on the template you want and click Open. It will throw it into QA, ready for you to adjust as your heart sees fit and then run to create the object you want. This is a very underused part of QA. I didn;t even realize it existed for a couple of years. Now I use it all the time.

Questions about posting. See faq183-874
Click here to learn Ways to help with Tsunami Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top