Solved

Lookup Values

Posted on 1998-10-07
1
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Conditions in Where clause 9 46
Linked Server - SP with Param to VIew 7 21
T-SQL Query - Group By Year 3 28
Connect Gridview column to Textbox in C# 2 36
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

763 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