SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Mutivalue in table by using TSQL/Store Procedure
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MIB
Starting Member

4 Posts

Posted - 03/16/2001 :  01:11:49  Show Profile  Reply with Quote
Hi All
I got table as below
Table1
ID Name Type
-- ---- ----
1 A C
1 J C
2 F D
2 K H
3 L P

I wnat to make new table as below by using TSQL/store procedure in SQL7

New Table
ID Name Type
-- ---- ----
1 A;J C;C
2 F;K D;H
3 L P

Please help me out if u can
PS: please send me a sql file if u can
many thanks

MIB

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 03/16/2001 :  11:29:12  Show Profile  Visit nr's Homepage  Reply with Quote
Would probably be better (and easier) to do this with temp table but without something like.

insert NewTbl
select ID, Name, Type
from Table1
where convert(varchar(10),id) + Name + Type
in (select min(convert(varchar(10),id) + Name + Type) from Table1 group by id)

while @@rowcount > 0
begin
update NewTable
set Name = Name + ';' + Table1.Name,
Type = Type + Table1.Type
from Table1
where convert(varchar(10),Table1.id) + Table1.Name + Table1.Type in (select min(convert(varchar(10),id) + Name + Type) from Table1 where convert(varchar(10),Table1.id) + Table1.Name + Table1.Type > convert(varchar(10),NewTable.id) + right(NewTable.Name,1) + right(NewTable.Type,1) group by id)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000