I am creating a Stored Proc and I need to be able to select the last added row, now this should be made easier by the fact that I have a smalldatetime column in the table that is added every time a new row is inserted. I use MSSQL 2005 and the construction of the table is this:
And the select statement that i have is this:
The @device_id_temp is just an int that is selected in another select statement in the Stored Proc, what I need is the last part of the where statement.
NormannTheDane
Code:
CREATE TABLE temp_sensor_table ( temp_id Int Identity PRIMARY KEY, device_id Int NOT NULL REFERENCES Devices(device_id), temp_value NVARChar(10) NOT NULL, temp_date smalldatetime NOT NULL DEFAULT GETDATE() )
Code:
select temp_value from temp_sensor_table where device_id = @device_id_temp and temp_date = ???
NormannTheDane
Comment