On 07/12/12 20:13, MB Software Solutions General Account wrote:
> I've seen how to create a rule for data in a column using direct values
> (http://www.databasejournal.com/features/mssql/article.php/3811831/Using-Check-Constraints-to-Validate-Data-in-SQL-Server.htm).
>
> But I want to basically say "Only allow values in this FK field that exist
> as PKs in that other table."
>
> How do I do that?
If you're doing lots and lots of them,
SELECT UNIQUE <pk-field> FROM <othertable> INTO ARRAY OKFields
keep the array around, then
IF ASCAN(OKFields, <FKvalue> > 0
-- it's good --
If this is a rare thing,
SELECT <pk-field> INTO ARRAY Dummy FROM <OTHERTABLE> ;
WHERE <pk-field> = <FKvalue>
if alen(Dummy) > 0
-- it's good --
Dan Covill
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.