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
)
CREATE function sales_union_func (
@assoc
) returns table AS return
select * from stock where assoc=@assoc
ASKER
I am sure but that didnt work. Any other suggestions?
--this returns results--
select top 1000 * from stock where assoc='SHM'
--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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I agree, if you want to pass a string, once you define the variable as string, it's ok to pass it like shown.
if yes:
select * from dbo.sales_union_func ( '''SHM''' )