Wednesday, March 7, 2012

Hyperthetical

Hi,

I am a noob and i have a hyperthetical question

I used to work with C-ASP and am moving to C# - asp.net with ms-SQL server

I have VS 2K5 pro with sql server developer

Just say I have a 30 or 40 table database with 80 colums in each table with various data types for each column

now is there anyway with t-sql to have the program create a "template" or installation file of the database (after i have created teh database in vs2k5 server explorer database connection) ?

What i mean by that is there a way that the probrams a

"create table <<tablename>>"

and builds the SQL for me for the table? if this does not make sense then please tell me and I will try and explain futher..

===

see what i did in the past was create a asp page with the design of the database in SQL and then when i FTP'd it to the server i could just run the page and it would install(create the tables) into the database and i would be able to uninstall(drop) the tables all the same way...

im looking for something similar..i have done it with an XML file, but it was the old way ,,where i had to manually write out the design of the database myself

Hi, fortunately in Management Studio we have a 'Template Explorer' (in the View Menu) which provides various templates including create database/table. You can download Management Studio Express from here:

http://msdn.microsoft.com/vstudio/express/sql/download

|||

Perhaps the use of the word template - i have been sick and my use of words inthe last 48 hours has not been as good as they have been...let me try and explain again.

You have designed a database and normalised this database on paper.

Then you create the database in ms-sql to the design on paper, but the database only exists locally

You would like the database schema in a file so that you can execute the design on the server and it is created exactly the same as locally(similar to a installation file but for the way database is for that solution)

I hope this makes more sense.

|||

pwpaust:

Perhaps the use of the word template **was wrong** - i have been sick and my use of words inthe last 48 hours has not been as good as they have been...let me try and explain again.

small correction

|||Ok that's goodSmile Then let's try Script Wizard in Management Studio: right click a database->Tasks->Generate Scripts. This wizard allows you to generate scripts for various database objects with some options, which you can use to create a database with exactly the same schema on another server.|||

hahahaha i just tried that...thats great

I could almost say i love you for answering this post...thanks :)

i appreciate it alot...

|||

if i was to "accidently drop the table" i made the script from

would you be able to point out how i might be able to restore it?

|||If you have dropped a table, I can't find the way to get it back unless there is a backup of the database which was made when the table have not been dropped. However, restore from the backup will bring the entire database to the 'status' when the backup was made.|||

no not a back up..i understand that i meant via that script method you mentioned

No comments:

Post a Comment