Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB SQL Gridview grid
I have a table that look like this:
CREATE TABLE [dbo].[Table](
	[IDRow] [int] NOT NULL,
	[Revision] [int] NOT NULL,
	[EntryDate] [datetime] NULL,
	[UserID] [int] NULL,
	[Title] [nvarchar](100) NULL,
	[TypeID] [nvarchar](10) NULL,
	[Tags] [nvarchar](max) NULL,
	[PriorityID] [nvarchar](10) NULL,
	[DeadlineDate] [datetime] NULL,
	[Description] [nvarchar](max) NULL,
 CONSTRAINT [PK__Table__A6C7A1C4145C0A3F] PRIMARY KEY CLUSTERED 
(
	[IDRow] ASC,
	[Revision] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
 
GO
It consists of a composite primary key which is meant to be shown to the user as a single column:
CAST(IDRow AS VARCHAR(4)) + '-' + CAST(Revision AS VARCHAR(3)) AS ItemNumber
 
So now I want to perhaps add some SQL to the Table_SelectAll Procedure that it only selects the row with the greatest revision number. There are and will be more rows like 1-0, 1-1, 1-2, 1-3...and I want to show only the 1-3 row.
 
Is it better to solve it inside the SELECT query or maybe in the code-behind while filling the gridControl? Either ways, please help to do this efficiently.
Using SQL Server 2008 R2, VS 2012 and coding in VB.
Posted 28-Jan-13 5:36am
dsagner384

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I'd suggest you do this if possible sql side. The reason being why return more data from SQL Server just to filter it out later on? It's just more network traffic and memory which is just going to get thrown away.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 369
1 Maciej Los 208
2 George Jonsson 144
3 Richard MacCutchan 140
4 Dave Kreskowiak 130


Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 28 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid