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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-05-30 : 08:57:44
|
| Marc writes "I've inherited an SQL Server 2000 application that does some spooky things in stored procedures. Any idea what might be a better way to do this little stored procedure; whose purpose is to tell if a station that _can_ be included in a market is, and if so, are all of them or just some...CREATE FUNCTION udf_IsStationCarrientInAllLineups( @intMarketID int, @intStationID int) RETURNS varchar(20) AS BEGIN RETURN (CASE (SELECT COUNT(DISTINCT tblLineup.LineupID)FROM tblLineup , tblChannelLineup, tblHubCommunity, tblCommunity, tblMarketCountyWHERE tblMarketCounty.MarketID = @intMarketID AND tblMarketCounty.CountyID = tblCommunity.CountyID AND tblCommunity.CommunityID = tblHubCommunity.CommunityID AND tblHubCommunity.HubID = tblLineup.HubID AND tblLineup.LineupID = tblChannelLineup.LineupID AND tblChannelLineup.StationID=@intStationID) WHEN 0 Then 'No Lineups'WHEN (SELECT COUNT(DISTINCT tblLineup.LineupID)FROM tblHubCommunity, tblCommunity, tblMarketCounty, tblLineupWHERE tblMarketCounty.MarketID = @intMarketID AND tblMarketCounty.CountyID = tblCommunity.CountyID AND tblCommunity.CommunityID = tblHubCommunity.CommunityID AND tblHubCommunity.HubID = tblLineup.HubID)THEN 'All Lineups' ELSE 'Some Lineups'" |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-05-30 : 09:23:08
|
| This is not a stored procedure, it is a user-defined function. Does it not work for you, ie meet requirement/biz rules? What is your definition of 'better'? If you are looking for performance improvements please post your ddl and indexes, along with some sample data.One thing I can say is you should convert these to ANSI style joins syntax for sure . . .<O>Edited by - Page47 on 05/30/2002 09:24:41 |
 |
|
|
|
|
|
|
|