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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-09-26 : 07:51:23
|
| Hannes Gouws writes "Hi,I am trying to create a view with a "virtual" column. The scenario:I have a table "Table1" with 3 columns called "ID", "From" and "To" respectively. My From col has a value of 10 and my To col a value of say 15. I want to create a view that will combine this two separate colums into one "virtual" column and give me the full list of:ID Value1 102 113 124 135 146 15instead of:ID From To1 10 15How will I go about doing this trick as I know that I'm a bit limited with the view.Kind regards,Hannes" |
|
|
dsdeming
479 Posts |
Posted - 2003-09-26 : 09:09:40
|
| You could try something like this:set nocount oncreate table #a( a int identity( 1, 1 ), FromVal int, ToVal int )insert into #a select 10, 15insert into #a select 37, 44select IDENTITY(int, 1,1) AS ID, s.Counterinto #outputfrom #a join sequence s on s.counter between #a.FromVal and #a.ToValselect * from #outputdrop table #adrop table #outputNote that this depends on the use of a sequence table. For more info on the use of such tables, you can search this site for "number table", "sequence table", or "tally table".Dennis |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2003-09-26 : 09:11:50
|
| You need to follow this link and format your question more like this and I'm sure you'll get some answer. Read the entire topic and see how many (quick) responses this person get when they provide this kind of information.[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=29085[/url] |
 |
|
|
|
|
|
|
|