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)
 Advanced Insert - help required

Author  Topic 

filf
Yak Posting Veteran

67 Posts

Posted - 2001-10-15 : 12:56:20


I have a history table logging all activity on a website. In most scenarios it is updated one row at a time but in one instance I need to perform a multi row insert/select, and I need to format data within the selection based on data in itself.

INSERT INTO team_history (hist_team_no,hist_season_no,hist_type,hist_desc,hist_id,hist_substitute,hist_score)
(SELECT team_no,@seasNo,'Transfer Complete','Unformatted',pId,subId,0 FROM team_players WHERE transfer_day = + @currentDay)


Now here is the trick, instead of inserting the string 'Unformatted' for hist_desc I wish to replace it with 'Player Name 1 has been sucessfully substituted with Sub Name'. The name data for subs and players is stored in another table that can be referenced by player_id. pId and subId are both player_id's.

I have tried a few tests with UNION into a temp table but it started to get a bit messy, so I thought I would ask the pros for advice.

Ultimately I would like to be put on the path to a solution which does not require me to iterate thru each record a row at a time formatting this hist_desc. I look forward to some ideas.


   

- Advertisement -