Solved

Lookup Values

Posted on 1998-10-07
1
188 Views
Last Modified: 2010-03-19
Does anyone know of a third-party-product that will allow a MS SQL 7 field to check another table to determine valid values?  This can't be done with a foreign key in my scenario and I don't believe it can be done in SQL.
0
Comment
Question by:scarlett
1 Comment
 
LVL 2

Accepted Solution

by:
formula earned 50 total points
ID: 1090447
Hi Scarlett!

To do what you want to do, you need to write a trigger.
A trigger will valid values in an insert or update from a lookup table.  It will be something like this:

create trigger validate_field
on data_table
for insert,update
as

if (select count(*) from data_table, inserted
       where lookup_table.field!=inserted.field) > 0
 begin
   rollback trans
   raiserror('Error inserting records, Value not valid,16,101)
 end
return
GO

This is not exact, but the general idea.  Let me know if you need any further assistance.

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now