Skip to Content.
Sympa Menu

freetds - Re: [freetds] Proper query to create table

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Igor Korot <ikorot01 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Proper query to create table
  • Date: Mon, 23 Jul 2018 05:57:49 -0700

Hi,

On Mon, Jul 23, 2018 at 2:48 AM, Frediano Ziglio <freddy77 AT gmail.com> wrote:
> 2018-07-22 7:57 GMT+01:00 Igor Korot <ikorot01 AT gmail.com>:
>> Hi, ALL,
>> I'm trying to execute following query:
>>
>> query1 = L"IF NOT EXISTS(SELECT 1 FROM sysobjects WHERE name =
>> 'abcatcol' AND type = 'U') CREATE TABLE abcatcol( <field_list>))";
>>
>> Unfortunately it fails.
>> If the table does not exist I'm getting 100 (SQL_NO_DATA) from the ODBC
>> driver.
>> And if the table does exist, I'm getting -1 with the error:
>>
>> "The table already exists".
>>
>> Is there a way to do this in 1 shot? Or I will have to do a conditional
>> for Sybase to make it in 2 queries?
>>
>> Please advise.
>>
>> Thank you.
>
> This works for mssql:
>
> if object_id('test123') is null create table test123(i int)

What about this one:

CREATE INDEX IF NOT EXISTS abcattbl_tnam_ownr ON abcattbl(\"abt_tnam\"
ASC, \"abt_ownr\" ASC)

?

It is on Sybase 16.
It says "Syntax error on the 'IF'".

Thank you.

>
> Frediano
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> https://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page