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 2000 Forums
 SQL Server Development (2000)
 sp_executesql parameters

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-07 : 09:03:34
Simon writes "I have a stored procedure that contains two varchars.
Embeded in the first is a number of codes that need to be replaced by other text. For Example 'My Name is *NAME*'

In order to replace the text correctly I have to look up a row in a table that has two columns, say 'CODE' and 'VARIABLE'. For Example CODE = '*NAME*', VARIABLE = '@Name'

What I have to do is replace the '*NAME*' part of the string in the variable with the contents of @Name, not the string '@Name'.

I have tried several ways of doing this using sp_executeSQL with both input and output parameters, but no matter how I try I always come to point where I cannot get at the contents of variable @Name.

Any Ideas ?

I am using SQL Server 7.0, Windows NT SP3."

nr
SQLTeam MVY

12543 Posts

Posted - 2002-03-07 : 10:58:28
Where is the variable @Name defined?
Where does it set?

Look at www.nigelrivett.com - there are some examples of passing and retrieving variables using sp_executesql.

If your table contains a reference to a variable name then I would try redesigning.
At least put the contents of the variables in to a temp table with the variable name and contents as fields - then you can join on that table and use a simple replace statement.



==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -