I assume that this is for SQL Server.
Objects containing the symbol] should be indicated with [].
In the following table:
CREATE TABLE [t]]] ( [i]]d] int primary key, [da]]]ta] int )
You can select it using:
SELECT [da]]ta], [i]]d] FROM [t]]]
If you are looking for a way to use T-SQL to quote object names, you can use QUOTENAME.
SELECT QUOTENAME('t]')
In SQL Server, you can also use double quotes to quote object names; however, there are two things to check.
First you need to make sure you enable QUOTED_IDENTIFIER. Some drivers will be for you automatically.
SET QUOTED_IDENTIFIER ON
The second thing you need to do is make sure that you avoid any other double quotes in the name of your object. From T-SQL, QUOTENAME reappears.
SELECT QUOTENAME('t"]') "t""]"
In VB.Net, you want to do something like:
dim queryStr As String = String.Format("SELECT ""{1}"" FROM dbo.myTable", String.Replace(col1, """", """"""))
source share