Well, in CF you would and could make a call to the table name, but place it
in a cftry block and getting the result

try

SELECT * FROM YOURTABLE

catch

   your code to check if it exists

/catch

/try

BUT  you are best to perform any checking in CF (assuming you are using SQL
Server)

DECLARE @vcUserTable varchar(500)

SET @vcUserTable = 'mychosentablename'

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name =
@vcUserTable)

     BEGIN

          SELECT 'TRUE'

          -- PRINT 'TRUE' -- < this will be ok

     END

ELSE

     BEGIN

          SELECT 'FALSE'

          -- PRINT 'FALSE'

     END

GO

Adding this into an SP will be a doddle and you can use it anywhere...

HTH

N



   _____  

From: techmike [mailto:[EMAIL PROTECTED]
Sent: 08 June 2004 13:21
To: CF-Talk
Subject: checking if a table exists?

Is it possible and if so how to check if a table exists?

I'm trying to add a automatic setup to my template, user specifies the
DSN, and the template will look to see if the tables exist, and if they
don't then create them with some basic entries..   I've never created
tables in CFM, but I assume CREATE TABLE will work?

-mike

   _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to