From jwcolby at gmail.com Fri Jul 24 12:38:19 2015 From: jwcolby at gmail.com (John W. Colby) Date: Fri, 24 Jul 2015 13:38:19 -0400 Subject: [dba-SQLServer] TSQL IF in a non-standard way Message-ID: <55B2780B.2060909@gmail.com> I am writing a stored procedure which uses "cascading" CTEs to grab a raw data set, and then transform that raw data set. For example I need "All the addressed in a table" joined to "all the addresses in another table". Simple enough. Then I do transforms looking for distances between the addresses in the two tables. Also simple enough. But Now sometimes I just need all addresses, sometimes I need only "specific counties" or "specific MSA numbers" or "specific states". I have to pull data from a CSV, a county list, or a state list, or an MSA list. What I am thinking is use an IF or switch to return a result set from a select. If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC Etc. This doesn't seem to work, or at least I can't find examples of this kind of use. IF seems to be used in TSQL to return specific values in fields inside of a select statement. Any suggestions for how to implement this? -- John W. Colby From paul.hartland at googlemail.com Fri Jul 24 12:43:18 2015 From: paul.hartland at googlemail.com (Paul Hartland) Date: Fri, 24 Jul 2015 18:43:18 +0100 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: <55B2780B.2060909@gmail.com> References: <55B2780B.2060909@gmail.com> Message-ID: The if's work different in sql server, you would need something like If @selector = 'ST' Begin Select xyz End Else if @selector = 'MSA' Begin Select abc End Paul On 24 Jul 2015 18:39, "John W. Colby" wrote: > > I am writing a stored procedure which uses "cascading" CTEs to grab a raw > data set, and then transform that raw data set. For example I need "All > the addressed in a table" joined to "all the addresses in another table". > Simple enough. > > Then I do transforms looking for distances between the addresses in the > two tables. Also simple enough. > > But Now sometimes I just need all addresses, sometimes I need only > "specific counties" or "specific MSA numbers" or "specific states". I have > to pull data from a CSV, a county list, or a state list, or an MSA list. > > What I am thinking is use an IF or switch to return a result set from a > select. > > If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC > > Etc. > > This doesn't seem to work, or at least I can't find examples of this kind > of use. IF seems to be used in TSQL to return specific values in fields > inside of a select statement. > > Any suggestions for how to implement this? > > -- > John W. Colby > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From davidmcafee at gmail.com Fri Jul 24 12:50:47 2015 From: davidmcafee at gmail.com (David McAfee) Date: Fri, 24 Jul 2015 10:50:47 -0700 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: <55B2780B.2060909@gmail.com> References: <55B2780B.2060909@gmail.com> Message-ID: SELECT CASE WHEN @Selector = 'ST' THEN XYZ WHEN @Selector = 'MSA' THEN ABC ELSE '???' END AS StrSelected FROM Some TABLE You can use Case like you would use an IIF() in Access (in a join, where clause)... On Fri, Jul 24, 2015 at 10:38 AM, John W. Colby wrote: > > I am writing a stored procedure which uses "cascading" CTEs to grab a raw > data set, and then transform that raw data set. For example I need "All > the addressed in a table" joined to "all the addresses in another table". > Simple enough. > > Then I do transforms looking for distances between the addresses in the > two tables. Also simple enough. > > But Now sometimes I just need all addresses, sometimes I need only > "specific counties" or "specific MSA numbers" or "specific states". I have > to pull data from a CSV, a county list, or a state list, or an MSA list. > > What I am thinking is use an IF or switch to return a result set from a > select. > > If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC > > Etc. > > This doesn't seem to work, or at least I can't find examples of this kind > of use. IF seems to be used in TSQL to return specific values in fields > inside of a select statement. > > Any suggestions for how to implement this? > > -- > John W. Colby > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Fri Jul 24 14:17:46 2015 From: fuller.artful at gmail.com (Arthur Fuller) Date: Fri, 24 Jul 2015 15:17:46 -0400 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: References: <55B2780B.2060909@gmail.com> Message-ID: I like both of the answers presented, but would push it one step further, and instead of using a SELECT statement in each case I would create separate SPs, each devoted to one of the cases, then EXEC the appropriate one, passing a parameter. That's an issue of personal taste; I haven't exhaustively benchmarked the differences. It's just my preference for what I call "atomic" procedures, that do precisely one thing with known input parameters. Arthur On Fri, Jul 24, 2015 at 1:50 PM, David McAfee wrote: > SELECT > CASE > WHEN @Selector = 'ST' THEN XYZ > WHEN @Selector = 'MSA' THEN ABC > ELSE '???' > END AS StrSelected > FROM Some TABLE > > You can use Case like you would use an IIF() in Access (in a join, where > clause)... > > On Fri, Jul 24, 2015 at 10:38 AM, John W. Colby wrote: > > > > > I am writing a stored procedure which uses "cascading" CTEs to grab a raw > > data set, and then transform that raw data set. For example I need "All > > the addressed in a table" joined to "all the addresses in another table". > > Simple enough. > > > > Then I do transforms looking for distances between the addresses in the > > two tables. Also simple enough. > > > > But Now sometimes I just need all addresses, sometimes I need only > > "specific counties" or "specific MSA numbers" or "specific states". I > have > > to pull data from a CSV, a county list, or a state list, or an MSA list. > > > > What I am thinking is use an IF or switch to return a result set from a > > select. > > > > If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC > > > > Etc. > > > > This doesn't seem to work, or at least I can't find examples of this kind > > of use. IF seems to be used in TSQL to return specific values in fields > > inside of a select statement. > > > > Any suggestions for how to implement this? > > > > -- > > John W. Colby > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- Arthur From jwcolby at gmail.com Sat Jul 25 01:25:43 2015 From: jwcolby at gmail.com (John W. Colby) Date: Sat, 25 Jul 2015 02:25:43 -0400 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: References: <55B2780B.2060909@gmail.com> Message-ID: <55B32BE7.6040901@gmail.com> This doesn't work. cteTestIf as ( if @Select = 'St' begin SELECT * from AZData; end ), returns compile error Msg 156, Level 15, State 1, Procedure usp_MoveData, Line 34 Incorrect syntax near the keyword 'if'. John W. Colby On 7/24/2015 1:43 PM, Paul Hartland wrote: > The if's work different in sql server, you would need something like > > If @selector = 'ST' > Begin > Select xyz > End > > Else if @selector = 'MSA' > Begin > Select abc > End > > Paul > On 24 Jul 2015 18:39, "John W. Colby" wrote: > >> I am writing a stored procedure which uses "cascading" CTEs to grab a raw >> data set, and then transform that raw data set. For example I need "All >> the addressed in a table" joined to "all the addresses in another table". >> Simple enough. >> >> Then I do transforms looking for distances between the addresses in the >> two tables. Also simple enough. >> >> But Now sometimes I just need all addresses, sometimes I need only >> "specific counties" or "specific MSA numbers" or "specific states". I have >> to pull data from a CSV, a county list, or a state list, or an MSA list. >> >> What I am thinking is use an IF or switch to return a result set from a >> select. >> >> If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC >> >> Etc. >> >> This doesn't seem to work, or at least I can't find examples of this kind >> of use. IF seems to be used in TSQL to return specific values in fields >> inside of a select statement. >> >> Any suggestions for how to implement this? >> >> -- >> John W. Colby >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From paul.hartland at googlemail.com Sat Jul 25 07:52:14 2015 From: paul.hartland at googlemail.com (Paul Hartland) Date: Sat, 25 Jul 2015 13:52:14 +0100 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: <55B32BE7.6040901@gmail.com> References: <55B2780B.2060909@gmail.com> <55B32BE7.6040901@gmail.com> Message-ID: I am out at the moment so cant do any testing but does it also error if you put select * from cteTestIf below the whole cte statement ? On 25 Jul 2015 07:26, "John W. Colby" wrote: > This doesn't work. > > cteTestIf as > ( > if @Select = 'St' > begin > SELECT * from AZData; > end > ), > > returns compile error > > Msg 156, Level 15, State 1, Procedure usp_MoveData, Line 34 > Incorrect syntax near the keyword 'if'. > > John W. Colby > > On 7/24/2015 1:43 PM, Paul Hartland wrote: > >> The if's work different in sql server, you would need something like >> >> If @selector = 'ST' >> Begin >> Select xyz >> End >> >> Else if @selector = 'MSA' >> Begin >> Select abc >> End >> >> Paul >> On 24 Jul 2015 18:39, "John W. Colby" wrote: >> >> I am writing a stored procedure which uses "cascading" CTEs to grab a raw >>> data set, and then transform that raw data set. For example I need "All >>> the addressed in a table" joined to "all the addresses in another table". >>> Simple enough. >>> >>> Then I do transforms looking for distances between the addresses in the >>> two tables. Also simple enough. >>> >>> But Now sometimes I just need all addresses, sometimes I need only >>> "specific counties" or "specific MSA numbers" or "specific states". I >>> have >>> to pull data from a CSV, a county list, or a state list, or an MSA list. >>> >>> What I am thinking is use an IF or switch to return a result set from a >>> select. >>> >>> If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC >>> >>> Etc. >>> >>> This doesn't seem to work, or at least I can't find examples of this kind >>> of use. IF seems to be used in TSQL to return specific values in fields >>> inside of a select statement. >>> >>> Any suggestions for how to implement this? >>> >>> -- >>> John W. Colby >>> >>> _______________________________________________ >>> dba-SQLServer mailing list >>> dba-SQLServer at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>> http://www.databaseadvisors.com >>> >>> >>> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jwcolby at gmail.com Sat Jul 25 08:00:36 2015 From: jwcolby at gmail.com (John W. Colby) Date: Sat, 25 Jul 2015 09:00:36 -0400 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: References: <55B2780B.2060909@gmail.com> <55B32BE7.6040901@gmail.com> Message-ID: <55B38874.30603@gmail.com> Yes. You must do what you are suggesting, however I am already doing that to select another CTE. IOW as long as you do that final select, it can select from any of the CTEs in the stored procedure. --select * from cteDiffDataAll --select * from cteDiffDataAllWithRowNum --select Top (1000) * from cteLastMove --select * from cteGeoDistance --SELECT COUNT(PKNew) AS Cnt, StNew, StOld FROM cteLastMove GROUP BY StNew, StOld --SELECT COUNT(PKNew) AS Cnt, StNew, DistanceCode FROM cteLastMoveDistance GROUP BY StNew, DistanceCode Select * from cteTestIf John W. Colby On 7/25/2015 8:52 AM, Paul Hartland wrote: > I am out at the moment so cant do any testing but does it also error if you > put select * from cteTestIf below the whole cte statement ? > On 25 Jul 2015 07:26, "John W. Colby" wrote: > >> This doesn't work. >> >> cteTestIf as >> ( >> if @Select = 'St' >> begin >> SELECT * from AZData; >> end >> ), >> >> returns compile error >> >> Msg 156, Level 15, State 1, Procedure usp_MoveData, Line 34 >> Incorrect syntax near the keyword 'if'. >> >> John W. Colby >> >> On 7/24/2015 1:43 PM, Paul Hartland wrote: >> >>> The if's work different in sql server, you would need something like >>> >>> If @selector = 'ST' >>> Begin >>> Select xyz >>> End >>> >>> Else if @selector = 'MSA' >>> Begin >>> Select abc >>> End >>> >>> Paul >>> On 24 Jul 2015 18:39, "John W. Colby" wrote: >>> >>> I am writing a stored procedure which uses "cascading" CTEs to grab a raw >>>> data set, and then transform that raw data set. For example I need "All >>>> the addressed in a table" joined to "all the addresses in another table". >>>> Simple enough. >>>> >>>> Then I do transforms looking for distances between the addresses in the >>>> two tables. Also simple enough. >>>> >>>> But Now sometimes I just need all addresses, sometimes I need only >>>> "specific counties" or "specific MSA numbers" or "specific states". I >>>> have >>>> to pull data from a CSV, a county list, or a state list, or an MSA list. >>>> >>>> What I am thinking is use an IF or switch to return a result set from a >>>> select. >>>> >>>> If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC >>>> >>>> Etc. >>>> >>>> This doesn't seem to work, or at least I can't find examples of this kind >>>> of use. IF seems to be used in TSQL to return specific values in fields >>>> inside of a select statement. >>>> >>>> Any suggestions for how to implement this? >>>> >>>> -- >>>> John W. Colby >>>> >>>> _______________________________________________ >>>> dba-SQLServer mailing list >>>> dba-SQLServer at databaseadvisors.com >>>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>> http://www.databaseadvisors.com >>>> >>>> >>>> _______________________________________________ >>> dba-SQLServer mailing list >>> dba-SQLServer at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>> http://www.databaseadvisors.com >>> >>> >>> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From paul.hartland at googlemail.com Mon Jul 27 22:41:46 2015 From: paul.hartland at googlemail.com (Paul Hartland) Date: Tue, 28 Jul 2015 04:41:46 +0100 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: <55B38874.30603@gmail.com> References: <55B2780B.2060909@gmail.com> <55B32BE7.6040901@gmail.com> <55B38874.30603@gmail.com> Message-ID: sorry for the delay but hmmmmm it appears you can't have an IF statement in a CTE, I had never tried it before....Just done a test setting up some CTE's then trying to select one using an IF afterwards and doesn't seem to work, sorry can't be of more help at the moment, I don't use CTE's very much at all I tend to just use temp tables etc, but would be interested to know how you resolved this one. Paul On 25 July 2015 at 14:00, John W. Colby wrote: > Yes. You must do what you are suggesting, however I am already doing that > to select another CTE. IOW as long as you do that final select, it can > select from any of the CTEs in the stored procedure. > > --select * from cteDiffDataAll > --select * from cteDiffDataAllWithRowNum > --select Top (1000) * from cteLastMove > --select * from cteGeoDistance > --SELECT COUNT(PKNew) AS Cnt, StNew, StOld FROM cteLastMove GROUP BY > StNew, StOld > --SELECT COUNT(PKNew) AS Cnt, StNew, DistanceCode FROM cteLastMoveDistance > GROUP BY StNew, DistanceCode > > Select * from cteTestIf > > > > John W. Colby > > > On 7/25/2015 8:52 AM, Paul Hartland wrote: > >> I am out at the moment so cant do any testing but does it also error if >> you >> put select * from cteTestIf below the whole cte statement ? >> On 25 Jul 2015 07:26, "John W. Colby" wrote: >> >> This doesn't work. >>> >>> cteTestIf as >>> ( >>> if @Select = 'St' >>> begin >>> SELECT * from AZData; >>> end >>> ), >>> >>> returns compile error >>> >>> Msg 156, Level 15, State 1, Procedure usp_MoveData, Line 34 >>> Incorrect syntax near the keyword 'if'. >>> >>> John W. Colby >>> >>> On 7/24/2015 1:43 PM, Paul Hartland wrote: >>> >>> The if's work different in sql server, you would need something like >>>> >>>> If @selector = 'ST' >>>> Begin >>>> Select xyz >>>> End >>>> >>>> Else if @selector = 'MSA' >>>> Begin >>>> Select abc >>>> End >>>> >>>> Paul >>>> On 24 Jul 2015 18:39, "John W. Colby" wrote: >>>> >>>> I am writing a stored procedure which uses "cascading" CTEs to grab a >>>> raw >>>> >>>>> data set, and then transform that raw data set. For example I need >>>>> "All >>>>> the addressed in a table" joined to "all the addresses in another >>>>> table". >>>>> Simple enough. >>>>> >>>>> Then I do transforms looking for distances between the addresses in the >>>>> two tables. Also simple enough. >>>>> >>>>> But Now sometimes I just need all addresses, sometimes I need only >>>>> "specific counties" or "specific MSA numbers" or "specific states". I >>>>> have >>>>> to pull data from a CSV, a county list, or a state list, or an MSA >>>>> list. >>>>> >>>>> What I am thinking is use an IF or switch to return a result set from a >>>>> select. >>>>> >>>>> If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC >>>>> >>>>> Etc. >>>>> >>>>> This doesn't seem to work, or at least I can't find examples of this >>>>> kind >>>>> of use. IF seems to be used in TSQL to return specific values in >>>>> fields >>>>> inside of a select statement. >>>>> >>>>> Any suggestions for how to implement this? >>>>> >>>>> -- >>>>> John W. Colby >>>>> >>>>> _______________________________________________ >>>>> dba-SQLServer mailing list >>>>> dba-SQLServer at databaseadvisors.com >>>>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>> http://www.databaseadvisors.com >>>>> >>>>> >>>>> _______________________________________________ >>>>> >>>> dba-SQLServer mailing list >>>> dba-SQLServer at databaseadvisors.com >>>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>> http://www.databaseadvisors.com >>>> >>>> >>>> >>>> _______________________________________________ >>> dba-SQLServer mailing list >>> dba-SQLServer at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>> http://www.databaseadvisors.com >>> >>> >>> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- Paul Hartland paul.hartland at googlemail.com From jwcolby at gmail.com Mon Jul 27 23:07:30 2015 From: jwcolby at gmail.com (John W. Colby) Date: Tue, 28 Jul 2015 00:07:30 -0400 Subject: [dba-SQLServer] TSQL IF in a non-standard way In-Reply-To: References: <55B2780B.2060909@gmail.com> <55B32BE7.6040901@gmail.com> <55B38874.30603@gmail.com> Message-ID: <55B70002.9000204@gmail.com> I haven't yet. I was counting on you Paul! ;) John W. Colby On 7/27/2015 11:41 PM, Paul Hartland wrote: > sorry for the delay but hmmmmm it appears you can't have an IF statement in > a CTE, I had never tried it before....Just done a test setting up some > CTE's then trying to select one using an IF afterwards and doesn't seem to > work, sorry can't be of more help at the moment, I don't use CTE's very > much at all I tend to just use temp tables etc, but would be interested to > know how you resolved this one. > > Paul > > On 25 July 2015 at 14:00, John W. Colby wrote: > >> Yes. You must do what you are suggesting, however I am already doing that >> to select another CTE. IOW as long as you do that final select, it can >> select from any of the CTEs in the stored procedure. >> >> --select * from cteDiffDataAll >> --select * from cteDiffDataAllWithRowNum >> --select Top (1000) * from cteLastMove >> --select * from cteGeoDistance >> --SELECT COUNT(PKNew) AS Cnt, StNew, StOld FROM cteLastMove GROUP BY >> StNew, StOld >> --SELECT COUNT(PKNew) AS Cnt, StNew, DistanceCode FROM cteLastMoveDistance >> GROUP BY StNew, DistanceCode >> >> Select * from cteTestIf >> >> >> >> John W. Colby >> >> >> On 7/25/2015 8:52 AM, Paul Hartland wrote: >> >>> I am out at the moment so cant do any testing but does it also error if >>> you >>> put select * from cteTestIf below the whole cte statement ? >>> On 25 Jul 2015 07:26, "John W. Colby" wrote: >>> >>> This doesn't work. >>>> cteTestIf as >>>> ( >>>> if @Select = 'St' >>>> begin >>>> SELECT * from AZData; >>>> end >>>> ), >>>> >>>> returns compile error >>>> >>>> Msg 156, Level 15, State 1, Procedure usp_MoveData, Line 34 >>>> Incorrect syntax near the keyword 'if'. >>>> >>>> John W. Colby >>>> >>>> On 7/24/2015 1:43 PM, Paul Hartland wrote: >>>> >>>> The if's work different in sql server, you would need something like >>>>> If @selector = 'ST' >>>>> Begin >>>>> Select xyz >>>>> End >>>>> >>>>> Else if @selector = 'MSA' >>>>> Begin >>>>> Select abc >>>>> End >>>>> >>>>> Paul >>>>> On 24 Jul 2015 18:39, "John W. Colby" wrote: >>>>> >>>>> I am writing a stored procedure which uses "cascading" CTEs to grab a >>>>> raw >>>>> >>>>>> data set, and then transform that raw data set. For example I need >>>>>> "All >>>>>> the addressed in a table" joined to "all the addresses in another >>>>>> table". >>>>>> Simple enough. >>>>>> >>>>>> Then I do transforms looking for distances between the addresses in the >>>>>> two tables. Also simple enough. >>>>>> >>>>>> But Now sometimes I just need all addresses, sometimes I need only >>>>>> "specific counties" or "specific MSA numbers" or "specific states". I >>>>>> have >>>>>> to pull data from a CSV, a county list, or a state list, or an MSA >>>>>> list. >>>>>> >>>>>> What I am thinking is use an IF or switch to return a result set from a >>>>>> select. >>>>>> >>>>>> If @Selector = 'ST' Select XYZ else if @Selector = 'MSA' Select ABC >>>>>> >>>>>> Etc. >>>>>> >>>>>> This doesn't seem to work, or at least I can't find examples of this >>>>>> kind >>>>>> of use. IF seems to be used in TSQL to return specific values in >>>>>> fields >>>>>> inside of a select statement. >>>>>> >>>>>> Any suggestions for how to implement this? >>>>>> >>>>>> -- >>>>>> John W. Colby >>>>>> >>>>>> _______________________________________________ >>>>>> dba-SQLServer mailing list >>>>>> dba-SQLServer at databaseadvisors.com >>>>>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>>> http://www.databaseadvisors.com >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> >>>>> dba-SQLServer mailing list >>>>> dba-SQLServer at databaseadvisors.com >>>>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>> http://www.databaseadvisors.com >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>> dba-SQLServer mailing list >>>> dba-SQLServer at databaseadvisors.com >>>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>> http://www.databaseadvisors.com >>>> >>>> >>>> _______________________________________________ >>> dba-SQLServer mailing list >>> dba-SQLServer at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>> http://www.databaseadvisors.com >>> >>> >>> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >