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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Splitting a record

Author  Topic 

Pete_N
Posting Yak Master

181 Posts

Posted - 2011-03-04 : 03:48:30
I have a stored procedure that returns 1 row with 32 fields. This return is being used in a vs silverlight datagrid. What would be useful is if i could split the sql row into two rows. is that possible?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-03-04 : 04:08:40
Yes.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Pete_N
Posting Yak Master

181 Posts

Posted - 2011-03-04 : 06:32:55
quote:
Originally posted by Peso

Yes.



N 56°04'39.26"
E 12°55'05.63"




Thank you for that answer. Can you share with me how to go about it
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-03-04 : 09:19:11
No wonder Peso has such high post count

What is the purpose of this split? If it's simply a presentation issue you should do it in your datagrid. The purpose of a database query is to get the data you need efficiently from the database, not to make it look nice. Splitting you output in to two rows in the database opens a whole series of issues...like data types for example. Is the data type of column 1 and 17 the same for example? 2 and 18?

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-03-04 : 18:56:24
If you want a real solution, post a real question including some sample data and expected outout.
For example do you want to split even/odd columns or lower/higher part?

Read about UNION ALL in Books Online. It is the key to your solution.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2011-03-06 : 07:12:21
In sql you can choose columns from rows you want to return. See select statement syntax in Books OnLine. In some cases you may consider creating database view.

Mirko

My blog: http://mirko-marovic-eng.blogspot.com/
Go to Top of Page
   

- Advertisement -