Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Seconds()
Message
De
10/02/2019 10:08:26
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
10/02/2019 09:44:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01666213
Message ID:
01666216
Vues:
58
>Thanks sir for helping
>
>But
>
>These codes will not update nSeconds column in SQLserver table.
>
>I need for sqlserver, please

For SQL you would need a strictly incremental key, or else you wouldn't be able to say what is the previous record - there is no "previous record" there, as the physical order of records is not guaranteed by anything. You wouldn't even be able to write updates without a key, bescause there's no "current record" either. Instead, each update statement needs a where clause.

Also, instead of VFP trick of using the same cursor twice, in SQL you would have to use a self-join in the update statement, which is where it gets complicated and, believe it or not, I haven't done it.

Perhaps an easier way would be to
declare @dmx, @dnow datetime;
select @dmx=max(date) from junk
select @dnow=getdate()
insert into junk (date, nseconds) values (@dnow, datediff(seconds, @dnow, @dmx)
IOW, don't write values without seconds and fill them in later - calculate them from the max datetime before inserting. If it's not the current datetime that you're inserting, then it's a different matter - this would be a stored procedure where you'd pass @dnow as a parameter, and the 2nd line would be
select @dmx=max(date) from junk where date<@dnow

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform