LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How using the "truncate table" (SQL)in labview

How using the "truncate table" (SQL)in labview?

ADO-tool or DB-tool?which VI?

0 Kudos
Message 1 of 5
(3,447 Views)

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.

http://www.medicollector.com
Message 2 of 5
(3,441 Views)

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"

Download All
0 Kudos
Message 3 of 5
(3,415 Views)

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).

http://www.medicollector.com
Message 4 of 5
(3,386 Views)

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.

0 Kudos
Message 5 of 5
(3,377 Views)