-1

When I use the Cashier table or some other tables that have small amounts of records the process proceeds and table is inserted into the external database. But when I change the cashier into the transaction database (400k+ records), Visual Studio reports an error near "Transaction" Help would be appreciated thanks.

Cashier Database (working)

Dim query As String = "select * into MyDatabase2.dbo.Cashier from bos_primary_db.dbo.Cashier"

Transaction Database (not working)

Dim query As String = "select * into MyDatabase2.dbo.Transaction from bos_primary_db.dbo.Transaction"

This is the error message:

Incorrect syntax near the keyword 'Transaction'

ekad
  • 14,056
  • 26
  • 43
  • 45
iamlawrencev
  • 140
  • 1
  • 10

1 Answers1

2

this is probably because Transaction is a reserved word in SQL. Depending on your RDBMS (that you didn't specify), there are ways to "escape" it:
for Sql Server, you should wrap reserved words in square brackets:

select * into MyDatabase2.dbo.[Transaction] from bos_primary_db.dbo.[Transaction]

For MySql you should use an apostrophe:

select * into MyDatabase2.dbo.`Transaction` from bos_primary_db.dbo.`Transaction`

For Oracle you should use double quotes:

select * into MyDatabase2.dbo."Transaction" from bos_primary_db.dbo."Transaction"

Note: You should always try to avoid using reserved words. This link describes my favorite way of do it.

Community
  • 1
  • 1
Zohar Peled
  • 76,346
  • 9
  • 62
  • 111