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 2005 Forums
 Transact-SQL (2005)
 Displaying data by splitting it

Author  Topic 

sudha12345
Starting Member

47 Posts

Posted - 2009-07-31 : 02:30:52
I had column CONCENTRATION in Table Drugs which had data like
100 mg/50 ml

now i want to display the data into 4 columns
100
mg
50
ml

How can i approach for that

Sudhakar

Sachin.Nand

2937 Posts

Posted - 2009-07-31 : 02:39:42
quote:
Originally posted by sudha12345

I had column CONCENTRATION in Table Drugs which had data like
100 mg/50 ml

now i want to display the data into 4 columns
100
mg
50
ml

How can i approach for that



Sudhakar


4 columns or 4 rows?

PBUH
Go to Top of Page

sudha12345
Starting Member

47 Posts

Posted - 2009-07-31 : 02:47:53
The data has to spillted into 4 rows

Sudhakar
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2009-07-31 : 02:52:56
declare @str as varchar(100)
set @str='100 mg/50 ml'
select @str
select parsename(Replace(REPLACE(@str,'/','.'),' ','.'),4),
parsename(Replace(REPLACE(@str,'/','.'),' ','.'),3),
parsename(Replace(REPLACE(@str,'/','.'),' ','.'),2),
parsename(Replace(REPLACE(@str,'/','.'),' ','.'),1)

PBUH
Go to Top of Page

sudha12345
Starting Member

47 Posts

Posted - 2009-07-31 : 02:58:05
Thanks a lot , how can we do it if i has to display it in 4 columns

Sudhakar
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2009-07-31 : 03:05:53
quote:
Originally posted by sudha12345

Thanks a lot , how can we do it if i has to display it in 4 columns

Sudhakar



Did you try it?
It is displaying in 4 columns.

PBUH
Go to Top of Page
   

- Advertisement -