| Author |
Topic  |
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 21:09:54
|
Table Name = Med
Med med1, med3, med5
I want to create a view that would be viewed like this:
Med med1 med3 med5
Any help is appreciated. Thanks |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2010 : 21:12:10
|
use one of the following CSVTable fnParseList
KH Time is always against us
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 21:32:28
|
| is it possible without creating a stored procedure? |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2010 : 22:01:09
|
those are function not stored procedure
KH Time is always against us
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 22:02:18
|
| i really don't understand how. |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2010 : 22:10:39
|
begin tran
-- Create a table for testing and for illustration of the function
create table Med
(
csvmed varchar(20)
)
-- Insert some sample data into the testing table
insert into Med (csvmed)
select 'med1, med2, med3' union all
select 'med4, med5, med6'
-- the Query. Which you can convert into a View easily
select stringval as med
from Med m
cross apply dbo.CSVTable(csvmed)
rollback
KH Time is always against us
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 22:14:37
|
am getting this error: Line 3: Incorrect syntax near 'apply'. |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2010 : 22:16:28
|
what is the version of your SQL Server ?
KH Time is always against us
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 22:16:58
|
| 2000 sir |
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 22:25:14
|
I got the error when I tried running this script:
select stringval as med from Med m cross apply dbo.CSVTable(csvmed)
|
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2010 : 22:28:57
|
CROSS APPLY is only available for SQL 2005/2008
KH Time is always against us
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 22:30:17
|
| any option for 2000? :( |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2010 : 22:30:21
|
for 2000, it will not be easy. What are you trying to achieve here ?
KH Time is always against us
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 22:32:24
|
i would like to have results that would like like this:
MED med1 med2 med3 med4 med5 med6
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 01/31/2010 : 22:47:52
|
Hi I tried it in 2005 but I got this message:
Invalid object name 'dbo.CSVTable'. |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 01/31/2010 : 23:38:03
|
quote: Originally posted by cutiebo2t
Hi I tried it in 2005 but I got this message:
Invalid object name 'dbo.CSVTable'.
see my 1st post. Get it from the link
KH Time is always against us
|
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 02/01/2010 : 01:10:41
|
I got it. What if I want it in a horizontal view. Like this:
med1 med2 med3 med4 med5 med6 |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22460 Posts |
Posted - 02/01/2010 : 01:16:20
|
quote: Originally posted by cutiebo2t
I got it. What if I want it in a horizontal view. Like this:
med1 med2 med3 med4 med5 med6
Where do you want to show the data?
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 02/01/2010 : 01:18:39
|
| in a view in a columnar format. thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22460 Posts |
Posted - 02/01/2010 : 01:36:12
|
quote: Originally posted by cutiebo2t
in a view in a columnar format. thanks
Are you going to display them in a front end application?
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 02/01/2010 : 01:56:15
|
| no backend |
 |
|
Topic  |
|