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
 Transact-SQL (2000)
 String Replacement (Relationship) in SQL?

Author  Topic 

adlo
Posting Yak Master

108 Posts

Posted - 2004-11-03 : 14:47:57
I was wondering if it is possible to do the following in sql instead of in the programming language itself.

I need to replace the following values in a sting field based on each user.
&FirstName;
&GenderHeShe;
&GenderHisHer;

I am writing an app that does a personality assessment.
Based on certain questions an numeric score is returned.

I have a Comment table which contains string comments based on the score achieved.

Comment Table (Links Comment to Category)
Comment_ID int,
Category_ID int,
Comment varchar(8000)

Category Table
Category_ID int,
CategoryName varchar(10),
MinValue int,
MaxValue int

User Table
User_ID
FirstName
Gender bit (0=Female,1=Male)

User_Category Table (Links User to a Category)
User_ID int,
Category_ID int
Comments sometimes contain the person's name in the string
e.g. I would recommend John because of .....

Comments also sometimes contain references to the person's gender
e.g. He/She: He is a good worker
and
His/Her: Because of his ability ....

My questions is:
Can one replace these values using SQL?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-11-03 : 15:03:32
use replace function...

select replace(stringToReplaceIn, '&FirstName;', Name) from MyTable

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -