Sign in to follow this  
Followers 0
valerio81

citect & MS SQL database

5 posts in this topic

Hi all, i'm using for a new project, a connection to a SQL database. I used in the past the connection to Access DB adding each minute a new line with lot of Citect Tags to do some reports. Now, in this project, i need to read every second (or 5 seconds maybe) last row and save the 3 parameters of the last row in 3 variables on CitectSCADA. the exaple could be like this ID Name Code Value 1 N_1 C_1 V_1 2 N_2 C_2 V_2 3 N_3 C_3 V_3 4 N_4 C_4 V_4 the customer add a row everytime he changes Name, Code and Value (example a new order) and i should read last information until the customer changes it again, adding another new line Have you any advice? I dont know very well how to use MS SQL query. Thank you Valerio

Share this post


Link to post
Share on other sites
I think something like this QUERY would work. SELECT * from table_name WHERE ID=IDENT_CURRENT('table_name')

Share this post


Link to post
Share on other sites
thank you very much. i test it next week and I let you know!

Share this post


Link to post
Share on other sites
thanks Chris, it works good! I have another question, i think last one:-) How can I read, for example last 4 rows? You think is ok to read ID column and keep higher value as last one and then make a query reading values from MAXID-4 to MAXID ? Or there is a simpler query? It's very funny to learn this new language:-D Thanks

Share this post


Link to post
Share on other sites
Depends on which SQL database you have. This one: SELECT TOP 4 FROM Table_Name; Or this one: SELECT * FROM Table_Name LIMIT 0 4; Might do the trick.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0