Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delimit a SQL Query

Status
Not open for further replies.

lah3233

MIS
Joined
Jul 15, 2003
Messages
33
Location
US
I have a database with 12 fields. When I select my data - I would like it to appear back like this:

1, 2, 3, 4 /N, 5, 6, 7, 8 /N, 9, 10, 11, 12 /N

I would like a /N appended to every fourth item - and like to have it returned as a single field. Is there a simple way to do this using a PL/SQL command and not using DTS?

Thanks!
 
PL/SQL and DTS Humm? Guess you meant T-SQL.

Anyway, could just do this:

Code:
select field1+','+
       field2+','+
       field2+','+
       field4+'/N,'+
       field5+','+
       field6+','+
       field7+','+
       field8+'/N,'+ ....

Of course you might need to do some CONVERTs depending on your datatypes, but this would give you the delimited output.

 
AHHHH!! PL/SQL that's ORACLE not Microsoft SQL Server. If that's REALLY the language you are using, you are in the wrong forum.

-SQLBill

Not all SQL is equal



SELECT 'forum' CASE [SQL TYPE]
WHEN 'MySQL' THEN 'forum436'
WHEN 'Access' THEN 'forum700', 'forum701', 'forum702', 'forum703', 'forum704', 'forum181'
WHEN 'ORACLE' THEN 'forum185' 'forum186', 'forum759'
 
I did mean T-SQL - sorry for the confusion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top