Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Better to split procedure?

Status
Not open for further replies.

GISql

Programmer
May 23, 2006
12
NO
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.
 
Yes, that's what I am doing now, but I was wondering if there is another better way then to use such a big SQL string build
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top