Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/* create a @gp variable to hold the various col name */
declare @gp varchar(500)
select @gp = ' '
/* create a cursor to retrieve all col names from a table except the one we don't want to group by */
declare @tmpCol varchar(20)
declare Cols cursor LOCAL FORWARD_ONLY READ_ONLY for
select b.name from sysobjects a, syscolumns b
where a.name = 'MyTable'
and a.id = b.id
and a.name != 'BarCode'
open Cols
fetch next from Cols into @tmpCol
while @@FETCH_STATUS=0
begin
/* add the new col name to the already existing list */
select @gp = @tmpCol + ',' + @gp
fetch next from Cols into @tmpCol
end
close Cols
deallocate Cols
/* remove the trailing comma from the list */
select @gp = substring(@gp,1,len(@gp)-1)
/* run the query */
declare @query varchar(1000)
set @query =
'
select * from MyTable group by '+@gp+'
'
exec(@query)