Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SP Structure advice

Author  Topic 

John Sourcer
Yak Posting Veteran

91 Posts

Posted - 2008-08-06 : 07:38:40
Hi All,

I currently use the following structure to get all or one?

CREATE PROCEDURE [dbo].[GetCountries]
@CountryID int
AS
BEGIN
SET NOCOUNT ON;

IF @CountryID = 0
BEGIN
SELECT Countries.Country FROM Countries
END
ELSE
BEGIN
SELECT Countries.Country FROM Countries WHERE ID = @CountryID
END

END



Is this the best way of doing this?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-06 : 07:42:09
[code]CREATE PROCEDURE [dbo].[GetCountries]
@CountryID int
AS
BEGIN
SET NOCOUNT ON;

SELECT Countries.Country
FROM Countries
WHERE ID = @CountryID
OR @CountryID = 0

END[/code]



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -