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 2005 Forums
 Transact-SQL (2005)
 please advice- better way to pass data 1 or 2 sets

Author  Topic 

johnstern
Yak Posting Veteran

67 Posts

Posted - 2007-06-14 : 10:51:59
I am contemplating two ways to pass data from the sqlserver to client

first I have a single record set, the information for showpic, showaddress, name is repeated then for each entry the user made in the forum

messageid | message | userID | name | address | | showpic | showaddress | showlocation
1 | my test1 | 1004 | peter | peter@mio.com | 1 | 1 | 1
2 | my test3 | 1003 | john | john@mio.com | 1 | 1 | 1
3 | my test3 | 1003 | john | john@mio.com | 1 | 1 | 1
4 | my test6 | 1005 | lucas | lucas@mio.com | 0 | 0 | 0
5 | my test6 | 1003 | john | john@mio.com | 1 | 1 | 1
6 | my test6 | 1003 | john | john@mio.com | 1 | 1 | 1


my question is, would it be better to keep these info as two separated recordsets and combine/process them in the client side, is it worth doing it ?
like this:
users
userID | name | address | | showpic | showaddress | showlocation
1004 | peter | peter@mio.com | 1 | 1 | 1
1003 | john | john@mio.com | 1 | 1 | 1
1005 | lucas | lucas@mio.com | 0 | 0 | 0

messages
messageid | message | userID
1 | my test1 | 1004
2 | my test3 | 1003
3 | my test3 | 1003
4 | my test6 | 1005
5 | my test6 | 1003
6 | my test6 | 1003




Kristen
Test

22859 Posts

Posted - 2007-06-14 : 11:03:28
I think it would be better to combine them client-side. They need to be Order By something common to both resultsets, and you need to ensure that both ARE Ordered By those column(s) - otherwise you'll never combine them client side!!

When the recordsets get large-ish pumping all the duplicate data [using the single recordset solution] is going to really bog things down

You may find that you cannot process both resultsets concurrently via a single database connection (and you may only find this with large recordsets!) so something to watch out for in debugging. You may want to pull all the data from the first resultset into an "array" of some sort in your application, and then issue the query for the second resultset. Or you may be using a SProc that returns two resultsets - in which case you'll have to store the first into an Array before you can get to the second!

Kristen
Go to Top of Page
   

- Advertisement -