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
 .NET Inside SQL Server (2005)
 Select max row

Author  Topic 

ElTerrible25
Starting Member

2 Posts

Posted - 2008-09-15 : 17:29:13
Hi...Im sorry if this doesnt fall into the correct category, but i am in a pretty big hurry. I am trying to retrive the maximum bid id in table. Then I want to increment the max id by 1 and insert a new record into the table. When I try to run what I have below, there is a conversion from varchar to int error. Should be a simple fix I would think. Thanks for your help ahead of time.




set ANSI_NULLS OFF
set QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE [procedure]
@input FLOAT,

AS
SET NOCOUNT ON

Declare @BidID INT

set @BidID = 'select TOP 1([BID-ID]) from table order by [BID-ID] DESC'

INSERT INTO table([Bid-ID],input)
VALUES(@BidID+1, @input)

hey001us
Posting Yak Master

185 Posts

Posted - 2008-09-15 : 17:34:32
Declare @BidID INT

select TOP 1 @BidID = [BID-ID] from table order by [BID-ID] DESC
INSERT INTO table([Bid-ID],input)
VALUES(@BidID+1, @input)

hey
Go to Top of Page

ElTerrible25
Starting Member

2 Posts

Posted - 2008-09-15 : 18:14:47
much thanks!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-16 : 00:04:28
quote:
Originally posted by ElTerrible25

much thanks!


will you be always inserting one record at a time? Also it would have been easier if you had defined identity property on Bid-ID column. This will get automatically incremented to next value for each inertion.
Go to Top of Page
   

- Advertisement -