-1

I have an update statement written in SQL, which is :

UPDATE student 
SET student.[studentno]=[enter studentno],
    student.[avg]=[avg value];

What is the benefit of using the square brackets around “enter studentno” and “avg value” and what does this statement do? Does it allow the user to enter the values to be updated?

GMc
  • 1,764
  • 1
  • 8
  • 26
T kmail
  • 39
  • 3

3 Answers3

2

Columns in square brackets usually are composed keywords or contain special characters or spaces.

Sometimes it's the norm to use them just for readability - you know it's a column name,

Carlos Alves Jorge
  • 1,919
  • 1
  • 13
  • 29
1

Square brackets are not standard SQL, they are proprietary extensions.

Erwin Smout
  • 18,113
  • 4
  • 33
  • 52
0

When a column name contains spaces or is a reserved word, the name needs to be escaped. Some databases use [ ] for that. For column "studentno" you don't need escaping, but it is not wrong to use it. If it were called "student no" (note the space), the brackets would be required.

Is this MS Access? That has the extra feature that when some term isn't defined in the table (such as your [enter studentno], I assume) it will ask the user for a value, using that text as a prompt.

Hans Kesting
  • 38,117
  • 9
  • 79
  • 111