So Dave, how would you rewrite this SP using DECODE to dynamically set the
ORDER BY?
CREATE PROCEDURE webclientacctholddaily @caccountid int, @OrderBy
varchar(50)
AS
DECLARE @mySQL nvarchar(500)
SET @mySQL = N'SELECT holdings.*,securities.* FROM holdings, securities
WHERE holdings.secid = securities.secid AND holdings.accountID=@xparam ORDER
BY '+ @OrderBy
EXEC sp_executeSQL @mySQL , N'@xparam int', @caccountid
----- Original Message -----
From: "Dave Watts" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, June 23, 2000 7:19 AM
Subject: RE: Stored Procedure
> > Does SQL have an equivalent to DECODE?
>
> Yes - CASE. Here's a comparison from SQL Server Books Online:
>
> Oracle:
> DECODE (test_value,
> expression1, value1
> [[,expression2, value2] [...]]
> [,default_value]
> )
>
> SQL Server:
> CASE test_value
> WHEN expression1 THEN value1
> [[WHEN expression2 THEN value2] [...]]
> [ELSE default_value]
> END
>
> In addition, T-SQL provides several functions which provide similar
if-then
> functionality, such as NULLIF and COALESCE.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
> voice: (202) 797-5496
> fax: (202) 797-5444
>
> --------------------------------------------------------------------------
----
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
>
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.