Re: Subquerie in CHECK Constrain
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 10/20/04
- Next message: Bonj: "Re: Is there a way to syntax check all stored procedures (without deferred name resolution)"
- Previous message: Tibor Karaszi: "Re: Finding User and Access"
- In reply to: Nuno Silva: "Re: Subquerie in CHECK Constrain"
- Next in thread: Gert-Jan Strik: "Re: Subquerie in CHECK Constrain"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 20 Oct 2004 07:43:20 +0200
> I'm so embaressed. It 's a foreign key. BUAAAAAA. :-(
Don't be. These things happens to all of us from time to time. :-)
I recall once retrieving a record set in VB, looping it and for each row, executing another
statement correlating a rows from the first recordset in the other query, and so on, 4 levels deep.
Lunch. During lunch I realized that I was mimicking a JOIN inside VB...
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "Nuno Silva" <NunoSilva@discussions.microsoft.com> wrote in message news:3C5AFC5C-29C4-4F27-8DD7-CB56B53B5A88@microsoft.com... > Kalen, Tibor, Gert and Robert, > > I'm so embaressed. It 's a foreign key. BUAAAAAA. :-( > > This tables that i?m designing are to receive data from XML files and they > gave me the .dtd of the XMl, and I was trying to design the tables with the > exact rules of the .dtd files. > Thanks once more, for your time. > > Nuno > > "Kalen Delaney" wrote: > >> Yep, I answered the specific question without thinking about exactly what >> was being done. >> Even the column names make it seem like we might be dealing with a foreign >> key. >> >> Thanks, Tibor! >> >> -- >> HTH >> ---------------- >> Kalen Delaney >> SQL Server MVP >> www.SolidQualityLearning.com >> >> >> "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in >> message news:eGZJGLgtEHA.4044@TK2MSFTNGP09.phx.gbl... >> > Return a scalar (0 or 1, for example). >> > >> > And pass a comma separated value in, which you in the function parse and >> > build a temp table with which you can drive the IN with a subquery. Some >> > alternatives found here: http://www.sommarskog.se/arrays-in-sql.html >> > >> > OTOH, this smells like you should have an ordinary foreign key instead? >> > >> > -- >> > Tibor Karaszi, SQL Server MVP >> > http://www.karaszi.com/sqlserver/default.asp >> > http://www.solidqualitylearning.com/ >> > >> > >> > "Nuno Silva" <NunoSilva@discussions.microsoft.com> wrote in message >> > news:8A7641D0-C343-4388-A645-6BA8986C658B@microsoft.com... >> >> OK, >> >> But what should I return? Table? Scalar? If I right understand, I can >> >> only >> >> use UDF that return scalar values to check constrains and the two columns >> >> that I'm trying to compare are char type, how I should I do it? >> >> >> >> Thanks >> >> >> >> "Kalen Delaney" wrote: >> >> >> >>> Hi Nuno >> >>> >> >>> You can't use a subquery, but you can use a User Defined Function in SQL >> >>> Server 2000. >> >>> The UDF can reference another table. >> >>> >> >>> -- >> >>> HTH >> >>> ---------------- >> >>> Kalen Delaney >> >>> SQL Server MVP >> >>> www.SolidQualityLearning.com >> >>> >> >>> >> >>> "Nuno Silva" <NunoSilva@discussions.microsoft.com> wrote in message >> >>> news:2B03F7F1-6DEF-43B8-848B-2E0F89E494FA@microsoft.com... >> >>> > Hi, >> >>> > I'm trying to create a check constrain that goes check in a table if >> >>> > the >> >>> > value exists. >> >>> > Something like: >> >>> > >> >>> > Natur_Jur IN ( SELECT ID_Natur_Jur FROM tblXML_V_NaturezaJuridica ) >> >>> > >> >>> > When I try to save the table I get one error message that I cannot >> >>> > have >> >>> > subqueries in check constrain, what I think that is very strange that >> >>> > SQL >> >>> > Server doesn't have this feature. >> >>> > >> >>> > I'm doing something wrong or is it true the message that I get? >> >>> > Thanks in advanced, >> >>> > Nuno Silva >> >>> > >> >>> >> >>> >> >>> >> > >> > >> >> >>
- Next message: Bonj: "Re: Is there a way to syntax check all stored procedures (without deferred name resolution)"
- Previous message: Tibor Karaszi: "Re: Finding User and Access"
- In reply to: Nuno Silva: "Re: Subquerie in CHECK Constrain"
- Next in thread: Gert-Jan Strik: "Re: Subquerie in CHECK Constrain"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading