Link to home
Start Free TrialLog in
Avatar of ubsmail
ubsmail

asked on

SQL Function variable quote passing

I have a function that I need to pass a variable of 'SHM' but I cannot figure out how to get the single quotes to pass in variable. Thanks in advance. I am using SQL Server 2000.

 
Function Query

select * from dbo.sales_union_func  
(
'SHM' -- Needs to pass as 'SHM' not SHM
 )

Open in new window

CREATE function sales_union_func (

    @assoc

	
) returns table AS return


select * from stock where assoc=@assoc

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

are you 200% sure that you need to pass quotes ?

if yes:

select * from dbo.sales_union_func  ( '''SHM'''  )
Avatar of ubsmail
ubsmail

ASKER

I am sure but that didnt work. Any other suggestions?
--this returns results--

select top 1000 * from stock where assoc='SHM'

Open in new window

 
--FUNCTION

CREATE function assoc_test (
    @assoc char
) returns table AS return

select top 1000 * from stock where assoc=@assoc

--QUERY
select * from assoc_test ('''SHM''')

--Does not return results

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree, if you want to pass a string, once you define the variable as string, it's ok to pass it like shown.