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
 help in select data from a column

Author  Topic 

divyaram
Posting Yak Master

180 Posts

Posted - 2012-03-14 : 03:41:57
Hi all,

I have data in a column like this

[1_DATA]as [Data1]
[2_DATA] as [Data2]
[4_DATA] as [Data3]
[5_DATA] as [Data5]
[6_FQI] as [Data6]
[7_DATA] as [Data7]
[8_DATA] as [Data8]
[9_DATA] as [Data9]
[10_DATA] as [Data10]

i want to get data like this

[Data1]
[Data2]
[Data3]
[Data5]
[Data6]
[Data7]
[Data8]
[Data10]
and also need data
[1_DATA]
[2_DATA]
[4_DATA]
[5_DATA]
[6_FQI]
[7_DATA]
[8_DATA]
[9_DATA]
[10_DATA]

Regards,
Divya

nasim.sona
Starting Member

7 Posts

Posted - 2012-03-14 : 04:13:12
HI Divya,

I think you are looking to separate two set of data from a columns,
I think you should look for substring function.



-Nasim
Go to Top of Page

divyaram
Posting Yak Master

180 Posts

Posted - 2012-03-14 : 04:51:57
S i tried that ... but it not working that I am confused

select
substring (TempColumn,1,20)as tempcolumn
from dbo.table1
where db like'%temp%'

BUt i have trim the data before 'as'

Regards,
Divya
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-14 : 12:54:07
if format is consistent just do like

SELECT PARSENAME(REPLACE(field,' as ','.'),1) AS val
FROM table
UNION ALL
SELECT PARSENAME(REPLACE(field,' as ','.'),2)
FROM table


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

Go to Top of Page
   

- Advertisement -