Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I query column names that contain square brackets?

Tags:

People also ask

Can SQL column names have brackets?

In SQL Server, we can specify the column name with space in square bracket or parenthesis.

What is [] in SQL query?

The brackets are required if you use keywords or special chars in the column names or identifiers. You could name a column [First Name] (with a space) – but then you'd need to use brackets every time you referred to that column. The newer tools add them everywhere just in case or for consistency.

What do square brackets mean in SQL?

The brackets are required if you use keywords, spaces, hyphens or special chars in the column names or identifiers. Using square brackets in SQL Statements allow the names to be parsed correctly.

How do you name a column with a special character in SQL?

For example, if you want to select the column with special character '#', the code should like this: var rows = dt. Select("","[#]");


I have a csv that I need to parse into a gridview in vb.net. If I do SELECT *, I get the data without issue. However, I am in a situation where I need to reference the actual column names. And problem is, I have no control over the app that generates the csv, and they make the column names enclosed in square brackets.

How the heck can I do something like this:

Dim cmdSelect As New OleDbCommand(SELECT "[name], [height] FROM myTable")

so I get a return of data?

So, in an effort to be perfectly clear: I have an app that creates a csv with the column headers [name] and [height] in a table called myTable, and for the life of me I can't figure out how to return [name] and [height] specifically.