Hi,
I have the following question: My SP has a paramter @GROUP_MODEL, and based on this value, a different query will be built, for example:
IF @GROUP_MODEL = '1'
begin
set @sql = 'SELECT MO.MODEL_TYPE AS SORTGROUP_3, ' +
'Max(M.SORTGROUP_2) SORTGROUP_2, '
/*'''0'' AS SORTGROUP_2, ' */
end
ELSE
begin
set @sql = 'SELECT M.SORTGROUP_2, ' +
'M.SORTGROUP_3, '
end
As you see a SQL string is built up. After this I also have to make a separate group by string and separate order by string.
The problem is that this is a small part of the query, so a most of it is still the same.
Is it still better to split the quest in two queries?
Best regards,
G.I.
I have the following question: My SP has a paramter @GROUP_MODEL, and based on this value, a different query will be built, for example:
IF @GROUP_MODEL = '1'
begin
set @sql = 'SELECT MO.MODEL_TYPE AS SORTGROUP_3, ' +
'Max(M.SORTGROUP_2) SORTGROUP_2, '
/*'''0'' AS SORTGROUP_2, ' */
end
ELSE
begin
set @sql = 'SELECT M.SORTGROUP_2, ' +
'M.SORTGROUP_3, '
end
As you see a SQL string is built up. After this I also have to make a separate group by string and separate order by string.
The problem is that this is a small part of the query, so a most of it is still the same.
Is it still better to split the quest in two queries?
Best regards,
G.I.