astromenix
Technical User
Hi everyone
I got a stored proc that is getting pretty big, and at this point I got some repeated functionality, which sounds like I need to create a UDF or a stored proc and call it from my main proc.
Wot I want to achieve is pass to the function two sets of periods
For exaple:
FROM TO
05/06/2005 05/29/2005
FROM TO
05/07/2005 05/08/2005
05/12/2005 05/12/2005
FINAL ARRAY OF PERIODS
FROM TO
05/06/2005 05/06/2005
05/07/2005 05/08/2005
05/09/2005 05/11/2005
05/12/2005 05/12/2005
05/13/2005 05/29/2005
Then I need to create a new set of period where the second ones will overwrite the first ones.
I was thinking that my best bet would have been to use FORXML and pass the array of periods in an XML-format, as a comma delimiter solution wouldn’t be as easy to implement as far as I can think about it.
Is there a way to store the xml inside an varchar variable inside my stored procedure?
I tried the next one
But gives me an error
‘The FOR XML clause is not allowed in a ASSIGNMENT statement.’
Any ideas wot can I do?
Thanx in advance for any help or advice
I got a stored proc that is getting pretty big, and at this point I got some repeated functionality, which sounds like I need to create a UDF or a stored proc and call it from my main proc.
Wot I want to achieve is pass to the function two sets of periods
For exaple:
FROM TO
05/06/2005 05/29/2005
FROM TO
05/07/2005 05/08/2005
05/12/2005 05/12/2005
FINAL ARRAY OF PERIODS
FROM TO
05/06/2005 05/06/2005
05/07/2005 05/08/2005
05/09/2005 05/11/2005
05/12/2005 05/12/2005
05/13/2005 05/29/2005
Then I need to create a new set of period where the second ones will overwrite the first ones.
I was thinking that my best bet would have been to use FORXML and pass the array of periods in an XML-format, as a comma delimiter solution wouldn’t be as easy to implement as far as I can think about it.
Is there a way to store the xml inside an varchar variable inside my stored procedure?
I tried the next one
Code:
DECLARE @FROM nvarchar(4000)
Select @FROM=PERIOD_FROM from PERIODS FOR XML RAW
But gives me an error
‘The FOR XML clause is not allowed in a ASSIGNMENT statement.’
Any ideas wot can I do?
Thanx in advance for any help or advice