Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check if table in SQL Server exists
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01673835
Message ID:
01673844
Vues:
32
Thank you. I will try this, just to learn something new.

>
>create table dbo.testX (xx000 int)
>GO
>INSERT INTO dbo.testX (xx000) values (1)
>GO
>CREATE SCHEMA [xxx]
>GO
>
>create table xxx.testX (xx000 datetime)
>GO
>INSERT INTO xxx.testX (xx000) values (getdate())
>GO
>
>select * from dbo.testX
>select * from xxx.testX
>go
>
>SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'testX'
>go
>
>
>MartinaJ
>
>>Hi Martina,
>>
>>This is the first time I am beginning to understand the schema (a little). Thank you!
>>Just a follow up question.
>>How would you add a table to the DB - using SSMS - with a different schema? (e.g. schema "my")
>>
>>>Hi,
>>>
>>>dbo.is default owner/schema for MSSQL and each database.
>>>The answer for your question is: Yes, because you can have in database two tables: dbo.anytable and my.anytable with different structure. "my" is next schema.
>>>
>>>MartinaJ
>>>
>>>>Hi,
>>>>
>>>>I need to check (from a VFP 9 application) if a table in the SQL Server DB exists. I found a pretty simple code in one of the online threads. The code is as follows:
>>>>
>>>>
>>>>IF not (EXISTS (SELECT * 
>>>>                 FROM INFORMATION_SCHEMA.TABLES 
>>>>                 WHERE TABLE_SCHEMA = 'DBO' 
>>>>                 AND  TABLE_NAME = 'MyTable'))
>>>>BEGIN
>>>>    print 'does not exists'
>>>>END
>>>>
>>>>
>>>>My question is about the Table_Schema. In general I still don't understand what is the SQL Schema. If I put the 'DBO' in the Table_Schema above, the code works; the table - if exists - is found. But could there be a case - in the customer SQL Server database - that I need to enter something different than 'DBO'? Or, to be safe, should I drop the TABLE_SCHEMA from the WHERE completely?
>>>>
>>>>TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform