| Author |
Topic |
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 16:27:50
|
| select product.serial_number, model.model_number, model.model_name,part_inventory.part_number, model_configuration.Where_the_Part_is_Used, model_configuration.Quantity_of_Part_Usedfrom model inner join model_configuration on model.model_number = model_configuration.model_number inner join part_inventory on model_configuration.part_number = part_inventory.part_numberinner join product on model.serial_number = product.serial_numberwhere product.serial_number = 1;when i execute this i get Msg 207, Level 16, State 1, Line 9Invalid column name 'serial_number'. it's referring tomodel.serial_number = product.serial_numberserial_number is the PK of product, but is a foreign key for model, so i dont know why it wont work. but i'm also pretty new to sql...lol |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 16:36:26
|
| Post the CREATE TABLE statements for both model and product.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 16:56:37
|
| Create table Model(Model_Number char(10) Primary key not null,Serial_Number char (10) not null,Model_Name varchar (20) not null,Product_Line varchar (20) not null,Size_ varchar (30) not null,Introduction_Date smalldatetime not null,Discontinuation_Date smalldatetime not null,Foreign Key (Serial_Number) references Product (Serial_Number));Create table Product(Serial_Number char (10) Primary key not null,Order_Serial_Number char (10) not null,Price dec (5,2) not null,Delievery_Date smalldatetime not null,Shipping_Instructions varchar (50) not null,Color_of_Bike varchar (15) not null,Bike_Size varchar (10) not null,Parts_Used_in_Assembly_Process varchar (20) not null,Foreign Key (Order_Serial_Number) references Order_ (Order_Serial_Number)); |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 17:01:21
|
| It looks fine to me, can't figure out why you are getting that error.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 17:06:02
|
| then maybe the data i inserted into the tables caused the problem?? not sure? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 17:11:40
|
| Data would not impact this. Just thought of something. Try using Serial_Number in your query instead of serial_number. There can be a difference, depends on your collation.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 17:12:52
|
| Msg 102, Level 15, State 1, Line 1Incorrect syntax near '='. that's what i get when i parse the line of code that the error was pointing to |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 17:15:39
|
| that doesn't seem to change anything |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 17:16:13
|
| You can't parse just that one line. You must parse an entire query. Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 17:19:03
|
| when i parse the entire query, it completes succesfully, and when i just execute the query, it has that same old error, is this a good thing? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 17:23:50
|
| The query is syntactically correct. You are getting the error at runtime. Run just this and let us know what happens:select product.serial_numberfrom model inner join product on model.serial_number = product.serial_numberwhere product.serial_number = 1Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 17:32:47
|
| Msg 207, Level 16, State 1, Line 4Invalid column name 'serial_number'.same error from before huh? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 17:40:33
|
| Now try this:select serial_number from productselect serial_number from modelTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 17:48:26
|
| Msg 207, Level 16, State 1, Line 3Invalid column name 'serial_number'.same thing happened with executing those 2 lines from before |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 18:14:33
|
| Do you get the error twice or once?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 18:17:46
|
| only once |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 18:19:11
|
| Run each query separately to determine which one errored. Whichever one that is, the column is not named serial_number in that table.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 18:22:22
|
| Copy/paste the results of the following query into this thread:SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME IN ('model', 'product')Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
packymyles
Starting Member
21 Posts |
Posted - 2008-04-23 : 18:27:29
|
| Product Serial_NumberProduct Order_Serial_NumberProduct PriceProduct Delievery_DateProduct Shipping_InstructionsProduct Color_of_BikeProduct Bike_SizeProduct Parts_Used_in_Assembly_ProcessModel Model_NumberModel Model_NameModel Product_LineModel Size_Model Introduction_DateModel Discontinuation_Date |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-23 : 18:29:05
|
| Model does not contain Serial_Number!!! Next time you show us the CREATE TABLE statement, make sure that you generate it from Management Studio rather than by hand. It would have saved me quite a bit of time.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-23 : 18:31:17
|
| That's funny. When SQL is there to script out table, why you have to do by hand.. |
 |
|
|
Next Page
|