Ich habe versucht, mich umzuschauen, aber ich konnte nichts finden, was mir helfen würde.
Ich versuche dies in SQL zu tun:
declare @locationType varchar(50);
declare @locationID int;
SELECT column1, column2
FROM viewWhatever
WHERE
CASE @locationType
WHEN 'location' THEN account_location = @locationID
WHEN 'area' THEN xxx_location_area = @locationID
WHEN 'division' THEN xxx_location_division = @locationID
Ich weiß, dass ich nicht '= @locationID' am Ende jedes einzelnen setzen muss, aber ich kann die Syntax nicht annähernd korrekt wiedergeben. SQL beschwert sich immer wieder über mein '=' in der ersten WHEN-Zeile ...
Wie kann ich das machen?