Search-in-table
This stored procedure search in structure data e.g. beauty competition. In DB if you have information about beauty contest such as Miss Universe, Miss World, Miss USA, Miss America – you can search all contestents or winner.
If you know name of winner and do not know what competition she won – you can pass the name and reterive code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
CREATE PROCEDURE [dbo].[beauty_competition_search] (@competition_name char(50), @competition_city char(50), @competition_country char(50), @year int, @winner char(50), @winner_country char(50) , @category char(20), @n int, @SortOrder int) AS SELECT top (@n) * from [mydatabase].[dbo].[Beautycompetition] where ((@competition_name = competition_name ) OR (@competition_name = 'all')) and ((@competition_city = competition_city ) OR (@competition_city = 'all')) and ((@competition_country = competition_country ) OR (@competition_country = 'all')) and ((@year = year ) OR (@year = 0)) and ((@winner = @winner ) OR (@winner = 'all')) and ((@winner_country = winner_country ) OR (@winner_country = 'all')) and ((@category = category) OR (@category='all')) order by year Desc, position asc GO |