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 |
|
mgandra
Starting Member
15 Posts |
Posted - 2005-11-06 : 11:12:14
|
| I have a table like the below:OrderId QueueId Template Subject RecdDtim SentDtim1 1 TEM1 Sub1 11/3/2005 8:10:10 11/3/2005 9:00:151 2 TEM3 Sub2 11/3/2005 10:25:45 11/3/2005 10:40:352 3 TEM1 Sub2 11/3/2005 11:45:35 11/3/2005 12:00:001 4 TEM2 Sub3 11/4/2005 10:25:00 11/4/2005 10/30:002 5 TEM3 Sub3 11/4/2005 11:56:00 11/4/2005 12:00:00I want to concatenate Template, Subject and SentDtim column values for each order and display results like the below:OrderId Email1 TEM1,Sub1,11/3/2005 | TEM3,Sub2,11/3/2005|TEM2,Sub3,11/4/20052 TEM1,Sub2,11/3/2005 | TEM3, Sub3, 11/4/2005Please help me how to write the sql query in SQL Server 2000 to insert the results in the above format into a temporary table so that I can join that temp table with another table on orderid column and bind the result set to a datagrid in .aspx (asp.net)page.Any help will be highly appreciated. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-11-06 : 13:55:56
|
| create table #a (orderid int , s varchar(4000))insert #a select orderid, min(QueueId + [Template Subject] + convert(varchar(8),SentDtim,112)) from tbl group by orderidwhile @@rowcount > 0insert #a select orderid, min(tbl.QueueId + tbl.[Template Subject] + convert(varchar(8),tbl.SentDtim,112)) from tblwhere #a.orderid = tbl.orderidand #a.s < tbl.QueueId + tbl.[Template Subject] + convert(varchar(8),tbl.SentDtim,112))==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|