Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a stored proceduere with a variable

Status
Not open for further replies.

HotBob

Programmer
May 26, 2006
37
GB
Hi there I am wanting to execute this stored procedure

Code:
DECLARE @String Varchar(8000)
SET @String = '''S501734'',''S510385'''

INSERT INTO #Output 
exec spt_rep_payable_status '( creditor.account_no in (' + @String + ') ) ', NULL, NULL, 'ZLV', '', '', '', '', 0, 0, 'Jul 20 2006', 'N', ',Approved,Paid,Part Paid,', ',Normal,', 'c', 'Y'

However, I receive the error:

Incorrect syntax near '+'.

Is it possible to run a stored procedure like this?
 
Can you post code for SP?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
It is very long. However, if I place the code

Code:
INSERT INTO #Output 
exec spt_rep_payable_status '( creditor.account_no in (''S501734'',''S510385'') ) ', NULL, NULL, 'ZLV', '', '', '', '', 0, 0, 'Jul 20 2006', 'N', ',Approved,Paid,Part Paid,', ',Normal,', 'c', 'Y'

It works fine. But the stored procedure doesn't work with my variable

Any ideas?
 
sorted, for example...

Code:
DECLARE @Ref Varchar(20)
SET @Ref = 'S501734'


DECLARE @String Varchar(8000)
SET @String = '( creditor.account_no in (''' + @Ref + ''',''S510385'') ) '

print @String

INSERT INTO #Output 
exec Tramps_Trial.tramps.spt_rep_payable_status @String, NULL, NULL, 'ZLV', '', '', '', '', 0, 0, 'Jul 20 2006', 'N', ',Approved,Paid,Part Paid,', ',Normal,', 'c', 'Y'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top