Page 1 of 1

TMSTable.Tablename := '[Database]'

Posted: Thu 04 Jul 2013 08:37
by jmuehlenhoff
Hi,

we've got a database that contains a table named '[dbo].[Database]'. I can query the table just fine, but the TMSTable component is unable to open this table.

SQL Server complains about incorrect syntax.

We're using SDAC 6.6.12

This is the table CREATE statement:

Code: Select all

CREATE TABLE [dbo].[Database] (
    [Database_ID] UNIQUEIDENTIFIER CONSTRAINT [DEF_Database_Database_ID] DEFAULT newid() NOT NULL,
    [Name] NVARCHAR(40) COLLATE Latin1_General_CI_AS NOT NULL,
    [Info] NVARCHAR(max) COLLATE Latin1_General_CI_AS,
    [ArchiveMode] INTEGER CONSTRAINT [DEF_Database_ArchiveMode] DEFAULT 0 NOT NULL,
    CONSTRAINT [PK_Database] PRIMARY KEY NONCLUSTERED ([Database_ID])
)
GO

CREATE UNIQUE CLUSTERED INDEX [IDX_Database_1] ON [dbo].[Database] ([Name] ASC)
GO
Edit:

In addition the TMSQuery component is able to open the table with 'SELECT * FROM [dbo].[Database]', but calling `Append` causes the same error message.

Re: TMSTable.Tablename := '[Database]'

Posted: Thu 04 Jul 2013 09:40
by AlexP
Hello,

Since "Database" is a reserved word, you should enable the QuoteName option in both MSTable and MSQuery for correct work with such names:

MSQuery1.Options.QuoteNames := True;
MSTable1.Options.QuoteNames := True;

Re: TMSTable.Tablename := '[Database]'

Posted: Thu 04 Jul 2013 09:43
by jmuehlenhoff
Thanks,

is there any disadvantage when enabling this option?

Re: TMSTable.Tablename := '[Database]'

Posted: Thu 04 Jul 2013 11:04
by AlexP
Hello,

This option is designed for quoting names when automatically generating queries, there are no problems when using this option.