2

This is how variables are declared:

CREATE FUNCTION Fn_custom_roomie_emails
(@htenant       NUMERIC(18), 
 @dtmoveout     DATETIME, 
 @lesseeonly    VARCHAR(3)= 'NO', 
 @relationship  VARCHAR(100),
 @listseparator VARCHAR(10) = '; ', 
 @nameseperator VARCHAR(10) = ', ', 
 @andfunction   VARCHAR(3) = 'NO', 
 @tenantemail   VARCHAR(100) = '') 

The function works fine when I execute in this way:

exec dbo.Fn_custom_roomie_emails(hmy, Getdate(), 'All', **'Roommate'**, ';', ' ', '', 'YES')

But now I want to pass multiple relationships as shown below:

exec dbo.Fn_custom_roomie_emails(hmy, Getdate(), 'All', **'Roommate', 'Guarantor'**, ';', ' ', '', 'YES')

So how can I do that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Omkar
  • 51
  • 5

1 Answers1

0

like Giorgos said Table-Valued Parameter.you can declare like this

    declare @relationship table (relationship varchar(100))
    INSERT INTO @relationship(relationship) values('Roommate');
  • It's not that simple. What you've shown here is a table variable, which you can't pass as a parameter. You need to define a table type first, then you can declare it, insert data into it, and finally pass it as a parameter. – Ben Thul Dec 23 '15 at 17:44