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
 General SQL Server Forums
 New to SQL Server Programming
 QUERY HELP FOR COMMA SEP

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-06-29 : 06:21:59

I HAVE TWO TABLES LIKE

TBL_ID

ID (PK) RATE
1 10
2 15
3 20
4 25
5 30

TBL_DETAIL

ID RATE DATE
1 10 '02-JAN-2012'
1 10 '02-FEB-2012'
1 10 '02-MAR-2012'
1 10 '05-MAR-2012'
1 10 '08-APR-2012'
1 10 '10-MAY-2012'
2 15 '02-JULY-2012'
2 15 '05-JULY-2012'
2 15 '08-AUG-2012'



NOW I NEED TO SHOW RECORDS LIKE

TBL_ID.ID , TBL_ID.RATE , TBL_DETAIL.DATE
1 10 '02-JAN-2012' , '02-FEB-2012', '02-MAR-2012' , '05-MAR-2012' , '08-APR-2012' , '10-MAY-2012'
2 15 '02-JULY-2012' , '05-JULY-2012' , '08-AUG-2012'



PLEASE SUGGETS


challenge everything

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-29 : 07:17:48
see
http://www.nigelrivett.net/SQLTsql/CSVStringSQL.html


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sshelper
Posting Yak Master

216 Posts

Posted - 2012-06-30 : 03:22:14
Here's a similar link: http://www.sql-server-helper.com/tips/comma-delimited-output.aspx

SQL Server Helper
http://www.sql-server-helper.com/tips/tip-of-the-day.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-01 : 01:03:18
though unrelated to original problem,one question remains. why are you storing date values as varchar in table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -