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.
| Author |
Topic |
|
rajsequel
Starting Member
8 Posts |
Posted - 2003-07-31 : 02:25:47
|
| Hi,I want to split a column and get as two in the interface using sql server.table structure with sample data is :MyMailBox =========MailId MailSubject MailAttachmentSize====== =========== ==================100 Hi - from raj 124 k, 220 k200 Hello anand.. 12 k300 urgent ...... 45 k, 100 kfrom the above i want to get from the third column(i.e MailAttachmentSize) based on the mail id ,ie. as for MailId 100 - 124k MailId 100 - 220 keg. Select MailAttachmentSize From MyMailBox want to get as two columns i.e after the "," want to split.rajesh |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2003-07-31 : 03:17:15
|
| hi rajeshhow aboutselect MailId,case when charindex(',',MailAttachmentSize ) > 0 then substring(MailAttachmentSize, 1, charindex(',',MailAttachmentSize )-1)else MailAttachmentSizeend,case when charindex(',',MailAttachmentSize ) > 0 then ltrim(substring(MailAttachmentSize, charindex(',',MailAttachmentSize )+1, Len(MailAttachmentSize)))else Nullendfrom MyMailBox--I hope that when I die someone will say of me "That guy sure owed me a lot of money" |
 |
|
|
rajsequel
Starting Member
8 Posts |
Posted - 2003-07-31 : 04:00:16
|
| Hi Mr.RRB,thank u soo much...yr query is working fine...regds.rajeshrajesh |
 |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-07-31 : 09:18:27
|
quote: Originally posted by rajsequelthank u soo much...yr query is working fine...
Thank you so much. Your query is working fine.Damian |
 |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2003-07-31 : 19:31:07
|
Hey MerkinI know what you mean. So few available posts we've gotta now resort to either writing lymmericks or correcting spelling and grammar.... --I hope that when I die someone will say of me "That guy sure owed me a lot of money" |
 |
|
|
|
|
|
|
|