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 |
|
compguyy
Starting Member
1 Post |
Posted - 2008-03-24 : 10:17:14
|
| Help me out how to solve this requirementTable_1Col1 Col2 Col3 Col41 101 Usr1 WRK12 101 Usr2 WRK1Table_2Col1 Msg101 User %1 Logged on %2Expected OutputUser Usr1 logged on WRK1User Usr2 logged on WRK1 |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2008-03-24 : 10:30:32
|
| Select 'User' + '' + Table_1.Col3 + 'logged on'+ '' + Table_1.Col4 as Output from Table_1 inner join Table_2 on Table_1.col2=Table_2.col1 |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-03-24 : 10:33:15
|
| [code]declare @t1 table( col1 int, col2 int, col3 varchar(10), col4 varchar(10))declare @t2 table( col1 int, msg varchar(50))insert @t1select 1, 101, 'Usr1', 'WRK1' union allselect 2, 101, 'Usr2', 'WRK1'insert @t2select 101, 'User %1 Logged on %2'select replace(replace(t2.msg, '%1', t1.col3), '%2', t1.col4)from @t1 t1 join @t2 t2 on t1.col2 = t2.col1[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|
|
|