Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Scripting tables

Author  Topic 

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-11 : 04:43:34
Dear friends,

I have alot of tables to create in sql server 2005. They are all ready to copy and paste. Is there a window where I can just script all in at once?

Thankyou very much

Chopsmum

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-04-11 : 04:45:42
you can open a new query window to run the script



--------------------
keeping it simple...
Go to Top of Page

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-11 : 04:49:04
Thanks Jen

This is the first table

CREATE TABLE tblSubjects(
SubjectsID,INT NOT NULL,
SubjectTitle,VARCHAR(100),
SubjectCode,INT,
SubjectDescription,VARCHAR(1000),
SubjectsTypeIndexID,INT NOT NULL,
ClassesID,INT NOT NULL,
SubjectsTaughtID,INT NOT NULL,
GradeLevelsID,INT NOT NULL,
)

This is the error message
The definition for column 'SubjectsID' must include a data type.

Its got integer dt

Whats wrong?

Chopsmum
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-04-11 : 04:58:43
After column name "," is not required..

CREATE TABLE tblSubjects(
SubjectsID INT NOT NULL,
SubjectTitle VARCHAR(100),
SubjectCode INT,
SubjectDescription VARCHAR(1000),
SubjectsTypeIndexID INT NOT NULL,
ClassesID INT NOT NULL,
SubjectsTaughtID INT NOT NULL,
GradeLevelsID INT NOT NULL,
)

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-11 : 05:03:04
thankyou soooo much

keep you posted

Chopsmum
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-11 : 05:13:59
Also read Create table in sql server help file for more informations

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-11 : 05:22:56
Thankyou to everyone. I have just started the most exciting geekstage of my life to date......ha ha ha

96 tables to look at now....


Cm
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-04-11 : 05:28:57
have fun then...

but you can actually script them out you know... right click the database, all tasks, generate sql script, then choose the objects and preview or save in a file





--------------------
keeping it simple...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-11 : 05:36:30
quote:
Originally posted by Chopsmum

Thankyou to everyone. I have just started the most exciting geekstage of my life to date......ha ha ha

96 tables to look at now....


Cm


quote:
"I have alot of tables to create in sql server 2005. They are all ready to copy and paste"

Just curious, where did these scritps from 97 tables come from ? Is it generated from somewhere or some tool ?



KH


Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-11 : 06:20:02
quote:
Originally posted by khtan

quote:
Originally posted by Chopsmum


......ha ha ha
96 tables to look at now....


Just curious, where did these scritps from 97 tables ....



Just Curious 96 or 97 Tables ?

Srinika
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-11 : 06:51:52
May be dtproperties is included

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-11 : 07:17:00
quote:
This is the first table

CREATE TABLE tblSubjects(

quote:
96 tables to look at now....





KH


Go to Top of Page

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-11 : 09:42:01
Dear Friends,

because there are so many tables to work with, I determined the relationships using Visio and also wrote the erd tables (with PK and FK1 etc) in excel. It took me ages - days infact to get the foreign keys in the right places. Well so far anyway. I then used string concatenation in excel to make my scripts as fast as possible. I know its cheating but lots more fun when you have to correct commas. I wasnt going to type all that stuff again, even in scripts, no way.

Im on my first diagram window pulling the relationships together.

Thankyou all for your help.

One thing Ive noticed....it would be good if the tables lined up alphabetically and squeezed into pages say S-T together. When I auto-arrange they string out for 22 horizontal pages. OMG!!!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-11 : 19:51:59
maybe you should consider using a database design tool



KH


Go to Top of Page
   

- Advertisement -