Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 select rows horizontal
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cortpcl
Starting Member

4 Posts

Posted - 08/21/2013 :  09:52:06  Show Profile  Reply with Quote
Hi,

I have rows in a sql database like this.

The number of rows can vary, also the Label Names can vary.



I need to convert into into new table, so i easier can use them in my asp.net page.


I know .net and c#.
Can anyone give me a hint?

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 08/21/2013 :  09:55:38  Show Profile  Reply with Quote
quote:
Originally posted by cortpcl

Hi,

I have rows in a sql database like this.

The number of rows can vary, also the Label Names can vary.



I need to convert into into new table, so i easier can use them in my asp.net page.


I know .net and c#.
Can anyone give me a hint?

How wide do you want it to go? If you have 10,000 names in the table, would there be 20,000+ columns ore more?
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 08/21/2013 :  10:29:32  Show Profile  Reply with Quote
Seeing as this is in the design & architecture section, from a design and architecture point of view, this design is really bad as is your output requirement. Can you provide any background into what you want to do and why? Then we'll help you redesign your database so it's a bit more "proper" and also a solution to your output (which is unlikely to be what you need. As James says, what if you have 1000000 rows/columns?)
Go to Top of Page

cortpcl
Starting Member

4 Posts

Posted - 08/21/2013 :  10:50:46  Show Profile  Reply with Quote
Yes, i know that the data isnt structured very well, unfortunately i cant do anything about that.
I found some code, which i tweaked to my needs.
Ill post for others to use.

create procedure [dbo].[GetFormsubmissions]
@formpageid int
AS
BEGIN

DECLARE @str varchar(max);

SET @str='';


SELECT @str=@str+',MAX(CASE WHEN Label='''+ Label +''' THEN FieldValue ELSE '''' END) AS ['+Label+']'
FROM (SELECT DISTINCT Label FROM [dbo].[FormValues] v INNER JOIN [dbo].[FormSubmissions] s ON s.[id]=v.[SubmissionId] WHERE s.[FormPageId]=@formpageid) AS A;

EXEC('
SELECT SubmissionId'+@str+'
FROM [dbo].[FormValues] v INNER JOIN [dbo].[FormSubmissions] s ON s.[id]=v.[SubmissionId] WHERE s.[FormPageId]=' + @formpageid + '

GROUP BY SubmissionId

');
END
Go to Top of Page

porcrim
Starting Member

13 Posts

Posted - 04/22/2018 :  03:25:07  Show Profile  Reply with Quote
<strong><a href="http://www.menswatches.cn/">swiss replica watches aaa+</a></strong><br><strong><a href="http://www.menswatches.cn/">swiss replica watches</a></strong><br>[b][url=http://www.menswatches.cn/]high quality replica watches for men[/url][/b][b]<a href="http://www.menswatches.cn/">watches</a>[/b][b][url=http://www.menswatches.cn/]swiss Mechanical movement replica watches[/url][/b]Breitling Bentley Watches,Breitling Watches Online#sddm{margin: 0 auto;padding: 0;z-index: 30;background-color:#F4F4F4;width: 80px;height:23px;float: right; margin-right: 70px;}#sddm li{margin: 0;padding: 0;list-style: none;float: left;font: bold 12px arial}#sddm li a{display: block;margin: 0 1px 0 0;padding: 4px 10px;width: 60px;background: #f4762a;color: #666;text-align: center;text-decoration: none}#sddm li a:hover{background: #49A3FF}#sddm div{position: absolute;visibility: hidden;margin: 0;padding: 0;background: #EAEBD8;border: 1px solid #5970B2}#sddm div a{position: relative;display: block;margin: 0;padding: 5px 10px;width: auto;white-space: nowrap;text-align: left;text-decoration: none;background: #EAEBD8;color: #2875DE;font: 12px arial}#sddm div a:hover{background: #49A3FF;color: #FFF}[url=http://www.menswatches.cn/]Language[/url][url=http://www.menswatches.cn/de/]DeutschDeutsch[/url][url=http://www.menswatches.cn/fr/]FrançaisFrançais[/url][url=http://www.menswatches.cn/it/]italianoItaliano[/url][url=http://www.menswatches.cn/es/] EspañolEspañol[/url][url=http://www.menswatches.cn/pt/]PortuguêsPortuguês[/url][url=http://www.menswatches.cn/jp/]??????[/url][url=http://www.menswatches.cn/ru/]russianRussian[/url]<a href="http://www.menswatches.cn/ar/"><img src="http://www.menswatches.cn/langimg/aricon.gif" alt="arabic" title=" arabic " height="15" width="24">Arabic</a><a href="http://www.menswatches.cn/no/"><img src="http://www.menswatches.cn/langimg/noicon.gif" alt="norwegian" title=" norwegian " height="15" width="24">Norwegian</a><a href="http://www.menswatches.cn/sv/"><img src="http://www.menswatches.cn/langimg/svicon.gif" alt="swedish" title=" swedish " height="15" width="24">Swedish</a>[url=http://www.menswatches.cn/da/]danishDanish[/url][url=http://www.menswatches.cn/nl/]NederlandsNederlands[/url][url=http://www.menswatches.cn/fi/]finlandFinland[/url][url=http://www.menswatches.cn/ie/]irelandIreland[/url][url=http://www.menswatches.cn/]EnglishEnglish[/url] Welcome! [url=http://www.menswatches.cn/index.php?main_page=login]Sign In[/url]or [url=http://www.menswatches.cn/index.php?main_page=create_account]Register[/url] <a href="http://www.menswatches.cn/index.php?main_page=shopping_cart"><img class="cart-icon empty float-left" src="http://www.menswatches.cn/includes/templates/polo/images/spacer.gif" /></a>Your cart is empty [url=http://www.menswatches.cn/]Powered by Zen Cart :: The Art of E-Commerce[/url] <a href="http://www.menswatches.cn/index.php">Home</a> <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html">Replica Breitling Watches</a> [url=http://www.menswatches.cn/replica-omega-watches-c-38.html]Replica OMEGA Watches[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html]Replica Breitling Watches[/url] Currencies US Dollar Euro GB Pound Canadian Dollar Australian Dollar Jappen Yen Norske Krone Swedish Krone Danish Krone CNYCategories[url=http://www.menswatches.cn/replica-patek-philippe-c-22.html]Replica Patek Philippe[/url][url=http://www.menswatches.cn/replica-audemars-piguet-c-54.html]Replica Audemars Piguet[/url][url=http://www.menswatches.cn/replica-breitling-watches-c-55.html]Replica Breitling Watches[/url][url=http://www.menswatches.cn/replica-omega-watches-c-38.html]Replica Omega Watches[/url][url=http://www.menswatches.cn/replica-rolex-watches-c-1.html]Replica Rolex Watches[/url][url=http://www.menswatches.cn/replica-tag-heuer-watches-c-47.html]Replica TAG Heuer Watches[/url]Featured - [url=http://www.menswatches.cn/featured_products.html] [more][/url][url=http://www.menswatches.cn/omega-de-ville-46797236-mechanical-female-form-omega-p-1030.html]Omega De Ville 4679.72.36 mechanical female form (Omega)[/url][url=http://www.menswatches.cn/omega-de-ville-46797236-mechanical-female-form-omega-p-1030.html]Omega De Ville 4679.72.36 mechanical female form (Omega)[/url]$54,283.00 $232.00Save: 100% off[url=http://www.menswatches.cn/omega-de-ville-48103301-mens-quartz-watch-omega-p-1032.html]Omega De Ville 4810.33.01 Men's quartz watch (Omega)[/url][url=http://www.menswatches.cn/omega-de-ville-48103301-mens-quartz-watch-omega-p-1032.html]Omega De Ville 4810.33.01 Men's quartz watch (Omega)[/url]$3,297.00 $201.00Save: 94% off[url=http://www.menswatches.cn/omega-de-ville-46736037-mechanical-female-form-omega-p-1027.html]Omega De Ville 4673.60.37 mechanical female form (Omega)[/url][url=http://www.menswatches.cn/omega-de-ville-46736037-mechanical-female-form-omega-p-1027.html]Omega De Ville 4673.60.37 mechanical female form (Omega)[/url]$30,896.00 $236.00Save: 99% off [url=http://www.menswatches.cn/]Home[/url] :: Replica Breitling WatchesReplica Breitling WatchesFilter Results by: Items starting with ... A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9Displaying [b]61[/b] to [b]72[/b] (of [b]328[/b] products) <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=5&sort=20a" title=" Previous Page ">[<< Prev]</a> <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=1&sort=20a" title=" Page 1 ">1</a> <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=5&sort=20a" title=" Previous Set of 5 Pages ">...</a> [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=4&sort=20a]4[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=5&sort=20a]5[/url] 6[/b] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=7&sort=20a]7[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=8&sort=20a]8[/url] <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=9&sort=20a" title=" Page 9 ">9</a> [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=10&sort=20a]10[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=11&sort=20a]...[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=28&sort=20a]28[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=7&sort=20a][Next >>][/url] [url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-automatic-movement-675-gig-date-rose-gold-aaa-watches-p-2132.html]Replica Fancy Breitling For Bentley Automatic Movement 6.75 Gig Date Rose Gold AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-automatic-movement-675-gig-date-rose-gold-aaa-watches-p-2132.html]Replica Fancy Breitling For Bentley Automatic Movement 6.75 Gig Date Rose Gold AAA Watches[/url]$1,660.00 $234.00Save: 86% off<a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2132&action=buy_now&sort=20a&page=6"><img src="http://www.menswatches.cn/includes/templates/polo/buttons/english/button_buy_now.gif" alt="Buy Now" title=" Buy Now " width="83" height="22" class="listingBuyNowButton" /></a>[url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-automatic-tourbillon-rose-gold-case-aaa-watches-p-2133.html]Replica Fancy Breitling For Bentley Automatic Tourbillon Rose Gold Case AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-automatic-tourbillon-rose-gold-case-aaa-watches-p-2133.html]Replica Fancy Breitling For Bentley Automatic Tourbillon Rose Gold Case AAA Watches[/url]$25,107.00 $232.00Save: 99% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2133&action=buy_now&sort=20a&page=6]Buy Now[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-gt-chronograph-automatic-with-blue-dial-aaa-watches-p-2135.html]Replica Fancy Breitling For Bentley GT Chronograph Automatic With Blue Dial AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-gt-chronograph-automatic-with-blue-dial-aaa-watches-p-2135.html]Replica Fancy Breitling For Bentley GT Chronograph Automatic With Blue Dial AAA Watches[/url]$2,053.00 $234.00Save: 89% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2135&action=buy_now&sort=20a&page=6]Buy Now[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-automatic-tourbillon-silver-case-aaa-watches-p-2134.html]Replica Fancy Breitling For Bentley Motors Automatic Tourbillon Silver Case AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-automatic-tourbillon-silver-case-aaa-watches-p-2134.html]Replica Fancy Breitling For Bentley Motors Automatic Tourbillon Silver Case AAA Watches[/url]$2,184.00 $231.00Save: 89% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2134&action=buy_now&sort=20a&page=6]Buy Now[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-automatic-tourbillon-skeleton-aaa-watches-p-2136.html]Replica Fancy Breitling For Bentley Motors Automatic Tourbillon Skeleton AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-automatic-tourbillon-skeleton-aaa-watches-p-2136.html]Replica Fancy Breitling For Bentley Motors Automatic Tourbillon Skeleton AAA Watches[/url]$6,951.00 $227.00Save: 97% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2136&action=buy_now&sort=20a&page=6]Buy Now[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-chronograph-valjoux-7750-movement-aaa-watches-p-2137.html]Replica Fancy Breitling For Bentley Motors Chronograph Valjoux 7750 Movement AAA Watches[/url]<a href="http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-chronograph-valjoux-7750-movement-aaa-watches-p-2137.html">Replica Fancy Breitling For Bentley Motors Chronograph Valjoux 7750 Movement AAA Watches</a>$25,581.00 $238.00Save: 99% off<a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2137&action=buy_now&sort=20a&page=6"><img src="http://www.menswatches.cn/includes/templates/polo/buttons/english/button_buy_now.gif" alt="Buy Now" title=" Buy Now " width="83" height="22" class="listingBuyNowButton" /></a>[url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-t-chronograph-automatic-with-brown-dial-aaa-watches-p-2138.html]Replica Fancy Breitling For Bentley Motors T Chronograph Automatic With Brown Dial AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-motors-t-chronograph-automatic-with-brown-dial-aaa-watches-p-2138.html]Replica Fancy Breitling For Bentley Motors T Chronograph Automatic With Brown Dial AAA Watches[/url]$7,135.00 $233.00Save: 97% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2138&action=buy_now&sort=20a&page=6]Buy Now[/url]<a href="http://www.menswatches.cn/replica-fancy-breitling-for-bentley-tourbillon-automatic-gold-casing-with-black-dial-aaa-watches-p-2139.html"><div style="vertical-align: middle;height:200px"><img src="http://www.menswatches.cn/images/_small//watches_26/Breitling-Watches/Replica-Fancy-Breitling-For-Bentley-Tourbillon.jpg" alt="Replica Fancy Breitling For Bentley Tourbillon Automatic Gold Casing With Black Dial AAA Watches" title=" Replica Fancy Breitling For Bentley Tourbillon Automatic Gold Casing With Black Dial AAA Watches " width="200" height="200" class="listingProductImage" id="listimg" /></div></a>[url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-tourbillon-automatic-gold-casing-with-black-dial-aaa-watches-p-2139.html]Replica Fancy Breitling For Bentley Tourbillon Automatic Gold Casing With Black Dial AAA Watches[/url]$2,364.00 $237.00Save: 90% off<a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2139&action=buy_now&sort=20a&page=6"><img src="http://www.menswatches.cn/includes/templates/polo/buttons/english/button_buy_now.gif" alt="Buy Now" title=" Buy Now " width="83" height="22" class="listingBuyNowButton" /></a>[url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-tourbillon-automatic-silver-case-with-rose-dial-aaa-watches-p-2140.html]Replica Fancy Breitling For Bentley Tourbillon Automatic Silver Case With Rose Dial AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-tourbillon-automatic-silver-case-with-rose-dial-aaa-watches-p-2140.html]Replica Fancy Breitling For Bentley Tourbillon Automatic Silver Case With Rose Dial AAA Watches[/url]$19,724.00 $233.00Save: 99% off<a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2140&action=buy_now&sort=20a&page=6"><img src="http://www.menswatches.cn/includes/templates/polo/buttons/english/button_buy_now.gif" alt="Buy Now" title=" Buy Now " width="83" height="22" class="listingBuyNowButton" /></a>[url=http://www.menswatches.cn/replica-fancy-breitling-for-bentley-working-chronograph-quartz-stainless-steel-aaa-watches-p-2141.html]Replica Fancy Breitling For Bentley Working Chronograph Quartz Stainless Steel AAA Watches[/url]<a href="http://www.menswatches.cn/replica-fancy-breitling-for-bentley-working-chronograph-quartz-stainless-steel-aaa-watches-p-2141.html">Replica Fancy Breitling For Bentley Working Chronograph Quartz Stainless Steel AAA Watches</a>$3,320.00 $239.00Save: 93% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2141&action=buy_now&sort=20a&page=6]Buy Now[/url][url=http://www.menswatches.cn/replica-fancy-breitling-navitimer-aaa-watches-p-2142.html]Replica Fancy Breitling Navitimer AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-navitimer-aaa-watches-p-2142.html]Replica Fancy Breitling Navitimer AAA Watches[/url]$28,675.00 $232.00Save: 99% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2142&action=buy_now&sort=20a&page=6]Buy Now[/url][url=http://www.menswatches.cn/replica-fancy-breitling-navitimer-automatic-tourbillon-with-black-dial-aaa-watches-p-2143.html]Replica Fancy Breitling Navitimer Automatic Tourbillon With Black Dial AAA Watches[/url][url=http://www.menswatches.cn/replica-fancy-breitling-navitimer-automatic-tourbillon-with-black-dial-aaa-watches-p-2143.html]Replica Fancy Breitling Navitimer Automatic Tourbillon With Black Dial AAA Watches[/url]$4,183.00 $230.00Save: 95% off[url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?products_id=2143&action=buy_now&sort=20a&page=6]Buy Now[/url] Displaying [b]61[/b] to [b]72[/b] (of [b]328[/b] products) [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=5&sort=20a][<< Prev][/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=1&sort=20a]1[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=5&sort=20a]...[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=4&sort=20a]4[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=5&sort=20a]5[/url] 6[/b] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=7&sort=20a]7[/url] <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=8&sort=20a" title=" Page 8 ">8</a> [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=9&sort=20a]9[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=10&sort=20a]10[/url] <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=11&sort=20a" title=" Next Set of 5 Pages ">...</a> [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=28&sort=20a]28[/url] [url=http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=7&sort=20a][Next >>][/url] .articles{width:900px; margin:0 auto;}.articles ul{width:900px; }.articles li{width:450px; float:left;} [url=http://www.menswatches.cn/index.php]Home[/url] [url=http://www.menswatches.cn/index.php?main_page=shippinginfo]Shipping[/url] [url=http://www.menswatches.cn/index.php?main_page=Payment_Methods]Wholesale[/url] [url=http://www.menswatches.cn/index.php?main_page=shippinginfo]Order Tracking[/url] [url=http://www.menswatches.cn/index.php?main_page=Coupons]Coupons[/url] <a href="http://www.menswatches.cn/index.php?main_page=Payment_Methods" target="_blank">Payment Methods</a> [url=http://www.menswatches.cn/index.php?main_page=contact_us]Contact Us[/url] [url=http://www.lisasorganics.org/]REPLICA OMEGA[/url] [url=http://www.lisasorganics.org/]REPLICA PATEK PHILIPPE[/url] <a href="http://www.lisasorganics.org/" target="_blank">REPLICA ROLEX</a> [url=http://www.lisasorganics.org/]REPLICA WATCHES[/url] [url=http://www.lisasorganics.org/]COPY WATCHES[/url] [url=http://www.lisasorganics.org/]REPLICA BREITLING[/url] <a href="http://www.menswatches.cn/replica-breitling-watches-c-55.html?page=6&sort=20a" ><IMG src="http://www.menswatches.cn/includes/templates/polo/images/payment.png"></a> Copyright © 2012-2015 All Rights Reserved. [b][url=http://www.menswatches.cn/]swiss replica watches aaa+[/url][/b][b]<a href="http://www.menswatches.cn/">swiss replica watches</a>[/b]
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000