Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 check if the table exists

Author  Topic 

issam
Starting Member

30 Posts

Posted - 2008-05-20 : 10:53:05
Hi,

This my first time using the link server to read the files directly from within SQL2005, so issues the following link:-

EXEC sp_addlinkedserver
@server = N'MYVFPSERVER', -- Your linked server name here
@srvproduct=N'Visual FoxPro 9', -- can be anything
@provider=N'VFPOLEDB',
@datasrc=N'"C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 9\Samples\data\testdata.dbc"'

After that i can open query and do the import issues, but how can check if the table exists before issues the query.

Best regards

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-20 : 10:57:03
Same way as you do for local server, only prefix linked server name this time:

if exists (select * from <server-name>.<db-name>.dbo.sysobjects where id = object_id(N'[dbo].[foo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
...


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Shrews14
Starting Member

37 Posts

Posted - 2008-05-20 : 11:33:19
I maybe wrong but the

IF EXISTS(SQL) function sounds the option!!

IF EXISTS(SELECT * FROM <TABLE> WHERE=(optional))
<IF EXISTS>
ELSE
<IF NOT EXISTS>

Go to Top of Page
   

- Advertisement -