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)
 Group all pages based on ID

Author  Topic 

kiran
Starting Member

30 Posts

Posted - 2006-10-11 : 19:14:54
I have a table like this:

CREATE TABLE PAGES(ID CHAR(32), PAGE_NAME VARCHAR(150), DT DATETIME)

PAGES
-----
GUID1 PAGE1 10/1/2006
GUID1 PAGE2 10/2/2006
GUID1 PAGE3 10/3/2006

GUID2 PAGE1 10/1/2006
GUID2 PAGE2 10/2/2006

GUID3 PAGE1 10/1/2006
GUID3 PAGE2 10/2/2006
GUID3 PAGE3 10/3/2006
GUID3 PAGE4 10/4/2006

I want to get the output as:

GUID1 PAGE1, PAGE2, PAGE3
GUID2 PAGE1, PAGE2
GUID3 PAGE1, PAGE2, PAGE3, PAGE4

Unfortunately I cannot use any stored procedures or cursors to achive this output. I need to do with SELECT Query.

Can anyone help on this?

Thanks in advance.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-11 : 20:17:12
"Unfortunately I cannot use any stored procedures or cursors to achive this output"
So use a UDF. http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-11 : 21:10:32
Note that if concatenated string exceeds 8000 characters, you need to use more than one variable.
If you use front end application, you can do concatenation there

Madhivanan

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

kiran
Starting Member

30 Posts

Posted - 2006-10-11 : 21:28:59
Thanks for your replies.

I cannot use UDF either. I know it sucks but the system on which i am using does not allow to use this.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-10-11 : 22:39:19
Homework?



CODO ERGO SUM
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-10-12 : 07:15:55
quote:
I cannot use UDF either. I know it sucks but the system on which i am using does not allow to use this.

SQL SERVER allows stored procs, cursors, and UDFs all day, every day. Therefor, this must be one of the following:
1) Homework
or
2) Access maybe?

Either way, sure looks like a cross tab report to me.

EDIT: how could i MISS saying "FORMAT IN THE FRONT END".

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -