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)
 QUERY

Author  Topic 

bpgupta
Yak Posting Veteran

75 Posts

Posted - 2007-08-01 : 05:50:41
Hi,

I am using sql 2000 and i need to show the records in some fashion,Now query is giving two records ,but i have to show the records in one row


CREATE TABLE [dbo].[TblMessageTo] (
[MesTO_ID] [int] IDENTITY (1, 1) NOT NULL ,
[MesTo_Mes_ID] [int] NOT NULL ,
[MesTo_User_ID] [int] NOT NULL ,
[MesTo_User_Id_To] [int] NULL ,
[MesTo_Email_Id_To] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[MesTo_IsActive] [bit] NOT NULL
) ON [PRIMARY]
GO


MesTO_ID MesTo_Mes_ID MesTo_User_ID MesTo_User_Id_To MesTo_Email_Id_To
55 46 25 25 NULL 1
56 46 25 1 NULL 1


select MesTo_User_Id_To from tblmessageto where mesto_mes_id =46
The above query is showing two records , but i have to show in one record.

I need to show the mesto_USer_Id_To to one rows,
So it should come like 25,1 or 1,25

Regards,
BPG

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-08-01 : 06:38:22
declare @mesto_USer_Id_To varchar(50)

Select @mesto_USer_Id_To = Isnull(cast(@mesto_USer_Id_To as varchar(50))+',','') + mesto_USer_Id_To
from mesto_mes_id =46

Select @mesto_USer_Id_To

--------------------------------------------------
S.Ahamed
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-01 : 07:10:29
If you want to show the data in front end application, you can easily do concatenation there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -