I am not sure what you are looking for but I wanted to give you some SQL
code that you could look at. If you are passing in the 3 columns as
paramaters then you wont need to do the selects.
[quoted text, click to view] > If TABLEA.FIELDA=2
> THEN
> IF TABLEA.FIELDB=YES
> THEN
> RepClass=1
> ELSE
> RepClass=2
> ENDIF
> ELSE
> RepClass=TABLEB.FIELDG
> ENDIF
Declare @TableAFieldAValue varchar(255)
Declare @TableAFieldBValue varchar(255)
Declare @TableBFieldGValue varchar(255)
Declare @repclass int
Select @TableAFieldAValue = fielda, @TableAFieldBValue = fieldb
From tableA
Select @TableBFieldGValue = fieldg
From tableB
if @TableAFieldAValue = 2
begin
if @TableAFieldBValue = 'yes' --if this is a boolen then you could
also do a 1
begin
set @repclass = 1
end
else
begin
set @repclass = 2
end
end
Else
begin
set @repclass = @TableBFieldGValue
end
select @repclass
--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com Tech Blog -
www.technologyis.com */
[quoted text, click to view] "Jim Moberg" <JimMoberg@discussions.microsoft.com> wrote in message
news:9642590D-6EC8-4B1E-B97C-D15484723E8E@microsoft.com...
> After looking at what I wrote I realized I have you the wrong code. Here
> is
> the correct line of code:
>
> RepClass:
> IIf(TABLEA.FIELDA=2,IIf(TABLEA.FIELDB=Yes,"1","2"),TABLEB.FIELDG)
>
> This is saying:
>
> If TABLEA.FIELDA=2
> THEN
> IF TABLEA.FIELDB=YES
> THEN
> RepClass=1
> ELSE
> RepClass=2
> ENDIF
> ELSE
> RepClass=TABLEB.FIELDG
> ENDIF
>
> Can this be done in T-SQL? If so then where and how do I do this?
>
> "Hilary Cotter" wrote:
>
>> I think it should be
>>
>> Create Table Mytable(NewC1ID int default 0) or
>>
>> Create Table Mytable(NewC1ID char default "0")
>>
>> --
>> Hilary Cotter
>> Director of Text Mining and Database Strategy
>> RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
>>
>> This posting is my own and doesn't necessarily represent RelevantNoise's
>> positions, strategies or opinions.
>>
>> Looking for a SQL Server replication book?
>>
http://www.nwsu.com/0974973602.html >>
>> Looking for a FAQ on Indexing Services/SQL FTS
>>
http://www.indexserverfaq.com >>
>>
>>
>> "Jim Moberg" <JimMoberg@discussions.microsoft.com> wrote in message
>> news:2AF2A6F3-C0DD-4590-8DE8-AE1D5B8FB42F@microsoft.com...
>> > I'm trying to convert an MS-Access query so that it uses T-SQL code in
>> > Query
>> > Analyzer. I'm stuck at one point. The MS-Access query has the
>> > following
>> > field definition and conditional statement:
>> >
>> > NewClID: IIf(IsNull([CL_ID]),"0",[CL_ID])
>> >
>> > How do I convert this to T-SQL. I have looked and looked for some
>> > examples
>> > of this and can't find any.
>> >
>> >
>>
>>
>>