Paula DiTallo
asked on
SQL Server 2005: Case Logic in Dynamic SQL
Hi Techies--
I am getting the error:
Incorrect syntax near the keyword 'as'.
...because I am trying to dub a column name within case/end logic. Does anyone have a suggestion on how to solve this issue?
I am getting the error:
Incorrect syntax near the keyword 'as'.
...because I am trying to dub a column name within case/end logic. Does anyone have a suggestion on how to solve this issue?
[begin snippet]
SET @Sql = N'
SELECT
pat.AssemblyNum as ''assemblyNumber'',
pat.PatternNum as ''patternNumber'',
pat.Corner as ''cornerNumber'',
class.PatClassTypeName as ''className'',
case
when pat.MatchTypeID = ''101'' then pat.Width/2 as ''repeatWidth''
else pat.Width as ''repeatWidth''
end ,
pat.Length as ''repeatLength'',
match.MatchTypeName as ''matchType'',
pat.CollectionID as ''collectionID'',
coll.CollectionName as ''collectionName''
FROM PatternClassType class, Collections coll, Patterns pat
LEFT OUTER JOIN MatchType match
ON pat.matchtypeid = match.matchtypeid
[end snippet]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER