|
hi everybody. i want to create this database on sql 2005 and i keep getting and error which i don't know what is it. hope somebody can help me. thank you.
here is the syntax, ( i get only 1. create database 2. CREATE TABLE category_master 3.CREATE TABLE user_master correct.
(comments are locked)
|
|
Evening, In looking at your code, I noticed a couple of things.
IE: should be If you want to try to fix those particular issues and see if that resolves your problem, let us know. If not, post back what error you might be getting and we can try to assist your further! Thanks! thanks for your anwser, but if i use master database it's still the same. still error.
Apr 23 '12 at 02:03 AM
kid_sagitarius
As another side note, @Shawn_Melton is correct. If your default database is 'Master' then all of the objects after the create table statement would be create in Master, which you probably don't want. As he mentioned, I would put a 'USE Shop' statement in your script to handle that.
Apr 23 '12 at 02:56 AM
JohnM
@john thanks a lot. all the table build successfully. only the problem here is foreign key. example here when i execute the foreign key command the error that i get, what is the problem? thanks
Apr 23 '12 at 07:36 AM
kid_sagitarius
The example in this comment has you creating a table with a foreign key constraint referencing itself...
Apr 23 '12 at 09:11 AM
ThomasRushton ♦
(comments are locked)
|
|
If you're creating all your Foreign Key constraints within the Create Table statements, then you need to be very careful to make sure that you create the base tables first before attempting to reference them. For example (in pseudocode): This will fail because the Order table declaration / definition references the Product table which doesn't exist at this point. If your schema is complex, it may be worth separating out the two stages so that all tables are built before the referential integrity is added, thus: (again, pseudocode):
(comments are locked)
|


Well you first create the database but never issue a USE statement for the database you just created. So you are creating the tables probably in the master database.