I've been using the following code for years to avoid the "File is in use" error when trying to open a table:
IF USED('mytable')
SELECT mytable
ELSE
SELECT 0
USE mytable
ENDIF
Recently, I have hit upon a problem where the table is open with an alias other than the table name. Since the USED function is testing the alias, it fails to detect that the table is open with the above code.
Does anyone know of a way to test if a table is open with the table name, rather than its alias? I am on the brink of writing a function that would LIST STATUS to a file and then parse the file, looking for the table name, but I thought that I would ask first before going to all that trouble.
Thanks, -- Dick![[bigglasses] [bigglasses] [bigglasses]](/data/assets/smilies/bigglasses.gif)
IF USED('mytable')
SELECT mytable
ELSE
SELECT 0
USE mytable
ENDIF
Recently, I have hit upon a problem where the table is open with an alias other than the table name. Since the USED function is testing the alias, it fails to detect that the table is open with the above code.
Does anyone know of a way to test if a table is open with the table name, rather than its alias? I am on the brink of writing a function that would LIST STATUS to a file and then parse the file, looking for the table name, but I thought that I would ask first before going to all that trouble.
Thanks, -- Dick
![[bigglasses] [bigglasses] [bigglasses]](/data/assets/smilies/bigglasses.gif)