11-27-2010 12:03 PM
How using the "truncate table" (SQL)in labview?
ADO-tool or DB-tool?which VI?
11-27-2010 01:33 PM - edited 11-27-2010 01:34 PM
The SQL syntax for this statement is described here:
http://msdn.microsoft.com/en-us/library/ms177570.aspx
Its very simple. Just:
TRUNCATE TABLE name_of_mytable
If you want to use NI's DB toolkit, use this VI:
http://zone.ni.com/reference/en-XX/help/370016E-01/lvdatabase/db_tools_execute_query/
But personally, I just use the ADO objects available in MDAC. Its free.
11-27-2010 10:08 PM
Thanks for your reply!
I used the VI "DB Tools Execute Query VI ".When I input the SQL statement"truncate table XXX" to this VI, there is an error,but I can use the "delete","drop"and other SQL statements.
Is the "ADO objects available in MDAC" the ADO-tool?I think I used the VIs.I didn't know how to using the "drop"and "truncate".Using the "ADOTool_ADO API.vi"?How to use it"
11-28-2010 12:19 PM
I wonder if the JET database does not allow the TRUNCATE TABLE command. You'll have to check the JET documentation to confirm this.
But could you use the DELETE command instead:
DELETE * FROM my_table_name
DELETE is very similar to TRUNCATE. It just doesn't fill up your transaction log. And it might be safer depending on your application (e.g. in case you want to restore from a backup).
11-28-2010 09:34 PM
In the example which I updated yesterday,the commond "delete from table" can be used.
the "truncate" will reset any identity columns to the default seed value, but the delete will not do this.
I think I find the resson why the "truncate" commond can't be used.I used the MS Access,but it doesn't support the "truncate" commond.
Thanks for your help,again.