Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please, important: group by

Status
Not open for further replies.

luigiida

Programmer
Mar 26, 2003
29
0
0
IT
Hi I'm trying to compile the following stored procedure but I receive an error message regarding the "group by":
--******************************
use test
GO
create proc proceduretest
@vertice1 [nvarchar](255)

AS
select @vertice1 as first, RefID as RefID
into firstTab
from start
group by @vetice1, RefID

GO
--*******************************
where is the error??
Thanks,
Luigi
 
Group by @Vertice1 not @vetice1
But put the error message it will be easier to help you
 
Does @vertice1 contain a column name?

In that case you must use dynamic SQL

Code:
create proc proceduretest
@vertice1 nvarchar(255)

AS
exec('select ' + @vertice1 + ' as first, RefID as RefID
into firstTab
from start
group by ' + @vetice1 + ' , RefID ')

Your query does not make much sense otherwise.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top