why "incorrect syntax near the keyword 'IN' " in sql2008 ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santhanalakshmi
    New Member
    • May 2009
    • 147

    why "incorrect syntax near the keyword 'IN' " in sql2008 ?

    Hi,

    In am running my query in SQL Server Management Studio(SQL 2008)

    when i run this

    Code:
     select * into san IN 'backup.mdb' from tablename


    i am facing the following error.I dont know to find it out...

    Msg 156, Level 15, State 1, Line 2
    Incorrect syntax near the keyword 'IN'.


    Help me out.Thanks in advance
    Last edited by Niheel; Sep 22 '10, 04:58 AM. Reason: removed bold
  • gpl
    New Member
    • Jul 2007
    • 152

    #2
    The problem is that you are using IN incorrectly
    IN is a function that returns true or false, it is generally used in the WHERE clause.
    Code:
    select * into san from tablename
    Is perfectly ok, it creates a table called san with the same structure as tablename and populates it with the data in tablename

    I think you should explain what it is that you are trying to achieve

    Comment

    • santhanalakshmi
      New Member
      • May 2009
      • 147

      #3
      hi,

      i am making a copy of the table in san table into 'backup.mdb' database la.

      Comment

      • gpl
        New Member
        • Jul 2007
        • 152

        #4
        Is backup.mdb an Access database ? Is it allowed to copy a table fron SQL Server into an Access database in SQL 2008 ?

        Comment

        • santhanalakshmi
          New Member
          • May 2009
          • 147

          #5
          No,
          i am making a new table 'san' and copying to other database.

          Comment

          • gpl
            New Member
            • Jul 2007
            • 152

            #6
            If I understand you correctly, Backup is the name of another database.
            Assuming it is on the same server, then you will have to prefix the new table with the database name and owner name, try this:
            Code:
            select * into backup.dbo.san from tablename
            This needs to be run in the context of the original database

            Comment

            • santhanalakshmi
              New Member
              • May 2009
              • 147

              #7
              hi,

              Code:
              select * into backup.dbo.san from aaa



              ERROR:
              Msg 156, Level 15, State 1, Line 1
              Incorrect syntax near the keyword 'backup'.


              Actually i am making a backup of the table into newtable and moving from this database to other database in the same machine.This is the query

              Code:
              [B]
               select * into san in 'backup.mdb' from tablename[/B]
              But i am facing incorrect syntax near 'IN'

              Comment

              Working...