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 |
|
Mauricio Moreno
Starting Member
18 Posts |
Posted - 2007-08-21 : 15:29:02
|
| not sure if this is possible... but lets say i make a select likeselect products, stock from tableand my rs ischair | 1couch | 3lamp | 2is there anyway in the select to make any row that has stock of more than 1 to make a new row... so my rs would come back aschaircouch couchcouchlamp lampAny info would be helpful...Thanks,~ moe |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2007-08-21 : 15:48:44
|
Not sure why you would want to do this...but you need a numbers tableDECLARE @x table(product varchar(255), stock int)INSERT INTO @x(product,stock)SELECT 'chair', 1 UNION ALLSELECT 'couch', 3 UNION ALLSELECT 'lamp', 2select *, product from @x x INNER JOIN numbers n on x.stock+1 > n Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
sbalaji
Starting Member
48 Posts |
Posted - 2007-08-23 : 01:55:25
|
| nice way to use numbers table,numbers tables should contain values from 1 to max(stock)Is there any way we can populate the numbers table dynamically,w.r.t to max stock value??? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-23 : 03:34:30
|
Yes, use the function made by MVJ.F_TABLE_NUMBER_RANGE E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|