Domanda

I'm unable to select from a table that contains & (ampersand). I'm querying the SQL Server database using VB.NET, the exception it throws is

incorrect syntax near '&'

Here's the code I'm using:

Using Com As New SqlCommand("SELECT * FROM Appointments&Results", Conn)
Using RDR = Com.ExecuteReader()
    If RDR.HasRows Then
        Do While RDR.Read
        'Get values here
        Loop
    End If
End Using
End Using

And here are queries that I've tried:

SELECT * FROM `Appointments&Results`
SELECT * FROM 'Appointments&Results'
SELECT * FROM `Appointments&&Results`
SELECT * FROM `Appointments&Results`

Any ideas?

È stato utile?

Soluzione

SELECT * FROM [Appointments&Results]

That answers your question.

My question is, who in the world named the table with an ampersand (&)?!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top