Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sending values to a SP..

Author  Topic 

laptop545
Starting Member

11 Posts

Posted - 2010-03-19 : 17:00:14
Hello all,

I am executing a SP using this :

exec PSP_GetPeople @uClientID,
'<root nocommunitynames="1">
<rows>
<row peopletypeid="317" fieldnameid="3795" criteriaid="611" andor="1">
<value>2010</value>
</row>
</rows>
</root>',
@xml output,
@sp_error output
Select @xml as data


Now, the values inside the xml which i am sending 317,3795,611,2010 are hard coded.

i also have those values in variables like @grad,@year so on(which i got from executing another sql statements)..

instead of hard coding can i use the variables to send to the SP...

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-03-19 : 17:47:15
Just use another variable:

DECLARE @v varchar(500)

SELECT @v = '<root nocommunitynames="1">
<rows>
<row peopletypeid="' + SomeColumn1 + '" fieldnameid="' + SomeColumn2 + '" criteriaid="' + SomeColumn3 + '" andor="1">
<value>' + SomeColumn4 + '</value>
</row>
</rows>
</root>'
FROM YourTable
WHERE...

Now use @v for your stored procedure.

Depending upon the data types of the columns, you may need to CONVERT them to varchar.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-20 : 01:40:46
are you trying to build these values from table fields? if yes, you can use for xml

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -