You should never need to use Dynamic SQL ;-)



Rick Melnyck wrote:

>I am trying to do this with dynamic SQL but it doesn't seem to like me calling 
>the user defined function.  Not sure if it is my syntax but the error I am 
>getting is 'Error 141: A SELECT statement that assigns a value to a variable 
>must not be combined with data retrieval operations'.
>
>Any ideas on where i am messing up?  Thanks.
>
>
>
>--------------------------------------------------------------------------------
>CREATE PROCEDURE [dbo].[P_RICKTEST]                                   
>                    @SCHOOL CHAR(20) = NULL AS
>                                                                               
>   
>   DECLARE @SQL        nvarchar(4000),                                  
>           @PARAMLIST  nvarchar(4000)
>                                                                         
>   SELECT @SQL =                                                         
>          'SELECT COUNT(COLLG_COD)
>           FROM         V_DEGR
>           WHERE    1=1'
>                                                                        
>   IF @SCHOOL IS NOT NULL
>                                           
>      SELECT @SQL = @SQL + ' AND COLLG_COD IN  (select ExtractedInt from 
> dbo.StringToBigIntTable(@xSCHOOL, ',')'
>                                                                        
>   SELECT @PARAMLIST = '@xSCHOOL   CHAR(20)'                             
>                       
>                                                                         
>   EXEC sp_executesql @SQL, @PARAMLIST,                                 
>                      @SCHOOL
>GO
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2401
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to