I’m new to SQL, so I apologize if this is a dumb question.
When do I need to use the brackets ‘[‘ and ‘]’ around schema and table names? Could I just use them always?
Now, suppose I did the following to create a table
CREATE TABLE [dbo].[table1] ([ID] VARCHAR(5))
This worked. I verified it by running a select statement. Suppose time goes on and I added a bunch of rows. Now if I want remove all the rows, should I be using delete or truncate? It seems I should be doing this
TRUNCATE [dbo].[table1]
But I keep getting incorrect syntax near ‘dbo’ or incorrect syntax near keyword TRUNCATE when I do this via jtds jdbc driver.
What am I missing with the syntax?
should be
brackets are used to allow for invalid column names like then ones that start with a number or have spaces in them
example
you can always use brackets, they are not required but guard against problematic column names