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.
| Author |
Topic |
|
Nick
Posting Yak Master
155 Posts |
Posted - 2003-09-22 : 13:14:59
|
| Hello-I'm trying to come up with a good way to replace a certain substring of a nvarchar with a corresponding field.For instance. I'd like to be able to pass a value (nvarchar) to a stored procedure such as "Hi, my name is %fname", and have the sproc return a recordset consisting of the string with %fname replaced by the the field fname for each record in the table.Ex:"Hi, my name is Nick""Hi, my name is Sarah""Hi, my name is Fubar"Eventually I'll need the sproc to handle a bunch of different abbreviations such as first, last, e-mail...I'm thinking there is probably a pretty easy way to do this. Does anyone have any insight? ThanksNick |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-09-22 : 13:18:59
|
| Have you looked up REPLACE in Books Online?Jay White{0} |
 |
|
|
Nick
Posting Yak Master
155 Posts |
Posted - 2003-09-22 : 13:21:44
|
quote: Originally posted by Page47 Have you looked up REPLACE in Books Online?Jay White{0}
No, but it is obvious to me now that I should have.Thanks! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-09-22 : 13:23:07
|
quote: Originally posted by Nick Hello-I'm trying to come up with a good way to replace a certain substring of a nvarchar with a corresponding field.For instance. I'd like to be able to pass a value (nvarchar) to a stored procedure such as "Hi, my name is %fname", and have the sproc return a recordset consisting of the string with %fname replaced by the the field fname for each record in the table.Ex:"Hi, my name is Nick""Hi, my name is Sarah""Hi, my name is Fubar"Eventually I'll need the sproc to handle a bunch of different abbreviations such as first, last, e-mail...I'm thinking there is probably a pretty easy way to do this. Does anyone have any insight? ThanksNick
It's not so much the replacement of the "parameter" as it is the string phrase. Can you store the phrase in a phrase table and pass the phrase id in?Or does it have to be dynamic. And if it is (highly) dynamic, how do you plan to account for all the possible parameter variations (%localClamBar)?And how many possible tables does the data reside in?Brett8-)SELECT @@POST=NewId()That's correct! It's an AlphaNumeric! |
 |
|
|
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2003-09-22 : 14:00:55
|
Just a note : If your name is F.U.B.A.RI would not want you putting data in my system!May Cause S.N.A.F.U MMMmmmmmm..... Wonder if I can design old fart Army guy Smilie for site.JimUsers <> Logic |
 |
|
|
|
|
|
|
|