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
 Newbie migrating from excel to databases

Author  Topic 

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-09 : 09:45:55
Dear Friends,

I am designing a web app using sql server 2005 as a the backend. I have spent an enormous amount of time designing the db tables and ensured that they are normalised. Many, as you would expect have reference to what I would call indexes which are linked via foreign keys. This may be a really dumb question but.....
How do I make a lookup referential table where the integers become categories not an exact reference value (just like we do when we use vlookup in excel)?

Sorry but I am a little confused.....Thanks for your help guys.

Chopsmum

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-09 : 09:49:37
The lookup table will be

create table myrefdata
(
myrefdata_id int ,
Description varchar(100)
)

in the referencing table you will have

create table main
(
....
myrefdata_id int ,
...
)

and you retrive the data by

select ...
myrefdata = mrd.Description ,
...
from main m
join myrefdata mrd
on m.myrefdata_id = mrd.myrefdata_id
.....



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-09 : 09:51:55
you can use a JOIN to "linked" it to reference table.

You can refer to the SQL Server Books OnLine for details.



KH


Go to Top of Page

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-09 : 09:57:27
Are you telling me that if the user input value is 15 and the table shows data such as
0 green
10 red
20 blue

it will look for the category and not have a hissy fit because there was no 15?

Chopsmum
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-09 : 10:08:47
You should not allow the user to input the value 15.

If the stored procedure should give back an error if it happens but the app should only allow the user to select entries that exist.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-04-09 : 15:23:19
Maybe you could provide some sample information.

Please read the hint link in my sig for a roadmap on what to post.



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

Chopsmum
Starting Member

38 Posts

Posted - 2006-04-09 : 20:42:59
Thankyou Guys, you have been very helpful.

I am starting to get the picture.....its hard when one application lends itself to one way of thinking and another is completely different.

I am just so excited to be learning.....

Thankyou
Go to Top of Page
   

- Advertisement -