|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help on SQL syntax ???Dear all,
I am using SQL 2000 with vs2003. I need to create a store procedure which get the LAST record which has been written in the database. What is teh way to get that record ? thnaks for your help regards serge Hi
How many table does the database have? What is at the same time users insert data in many tables? One option is create a new columns as datetime (DEFAULT GETDATE()) for inserting .For updating you will have to create a trigger for update to track the changes. Show quote "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in message news:78D429C3-3519-45FA-ADD8-C952D199D47D@microsoft.com... > Dear all, > > I am using SQL 2000 with vs2003. > I need to create a store procedure which get the LAST record which has > been > written in the database. > > What is teh way to get that record ? > > thnaks for your help > > regards > serge I only need to return a single row from a database table which already
contains a DateTime field. I have tried to use the TOP keyword as follow in a strore procedure: SELECT TOP ID, LEN, START_TIME FROM REELHIST ORDER BY START_TIME DESC But it return a syntax error message when checking the syntax Any idea ? regards serge Show quote "Uri Dimant" wrote: > Hi > How many table does the database have? > What is at the same time users insert data in many tables? > > One option is create a new columns as datetime (DEFAULT GETDATE()) for > inserting .For updating you will have to create a trigger for update to > track the changes. > > > > "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in > message news:78D429C3-3519-45FA-ADD8-C952D199D47D@microsoft.com... > > Dear all, > > > > I am using SQL 2000 with vs2003. > > I need to create a store procedure which get the LAST record which has > > been > > written in the database. > > > > What is teh way to get that record ? > > > > thnaks for your help > > > > regards > > serge > > > SELECT TOP 1 ID, LEN, START_TIME FROM REELHIST ORDER BY START_TIME DESC
Show quote "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in message news:486F2059-0EE0-4CF6-8687-3C5F707EE77F@microsoft.com... >I only need to return a single row from a database table which already > contains a DateTime field. > > I have tried to use the TOP keyword as follow in a strore procedure: > > SELECT TOP ID, LEN, START_TIME FROM REELHIST ORDER BY START_TIME DESC > > But it return a syntax error message when checking the syntax > > Any idea ? > > regards > serge > > "Uri Dimant" wrote: > >> Hi >> How many table does the database have? >> What is at the same time users insert data in many tables? >> >> One option is create a new columns as datetime (DEFAULT GETDATE()) for >> inserting .For updating you will have to create a trigger for update to >> track the changes. >> >> >> >> "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in >> message news:78D429C3-3519-45FA-ADD8-C952D199D47D@microsoft.com... >> > Dear all, >> > >> > I am using SQL 2000 with vs2003. >> > I need to create a store procedure which get the LAST record which has >> > been >> > written in the database. >> > >> > What is teh way to get that record ? >> > >> > thnaks for your help >> > >> > regards >> > serge >> >> >> thnaks,
so simple sometimes :-) Show quote "Uri Dimant" wrote: > SELECT TOP 1 ID, LEN, START_TIME FROM REELHIST ORDER BY START_TIME DESC > > "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in > message news:486F2059-0EE0-4CF6-8687-3C5F707EE77F@microsoft.com... > >I only need to return a single row from a database table which already > > contains a DateTime field. > > > > I have tried to use the TOP keyword as follow in a strore procedure: > > > > SELECT TOP ID, LEN, START_TIME FROM REELHIST ORDER BY START_TIME DESC > > > > But it return a syntax error message when checking the syntax > > > > Any idea ? > > > > regards > > serge > > > > "Uri Dimant" wrote: > > > >> Hi > >> How many table does the database have? > >> What is at the same time users insert data in many tables? > >> > >> One option is create a new columns as datetime (DEFAULT GETDATE()) for > >> inserting .For updating you will have to create a trigger for update to > >> track the changes. > >> > >> > >> > >> "serge calderara" <sergecalder***@discussions.microsoft.com> wrote in > >> message news:78D429C3-3519-45FA-ADD8-C952D199D47D@microsoft.com... > >> > Dear all, > >> > > >> > I am using SQL 2000 with vs2003. > >> > I need to create a store procedure which get the LAST record which has > >> > been > >> > written in the database. > >> > > >> > What is teh way to get that record ? > >> > > >> > thnaks for your help > >> > > >> > regards > >> > serge > >> > >> > >> > > > |
|||||||||||||||||||||||