February 20, 2008 at 7:46 pm
Can Define an Identifier statring with "[" and ending with "]"
.....
JI.InvoiceTitle = [Jobs].[InvoiceTitle]
.....
Is the above format correct?
and why is [] used in SQl scripts
thanks
February 20, 2008 at 8:32 pm
SQL Server will generate these for your field and table names just in case they contain an invalid character.
For example, your table name can contain spaces (IMHO a ver bad practice), but then to select from in you would need:
Select * From [My Table]
February 20, 2008 at 11:17 pm
Moreover two more things are there as for as my concern.
1.Use brackets to enclose a range of characters, such as [a-f]
2.Use a reserved word as a field name. For instance, [date]
February 21, 2008 at 12:55 pm
In dynamic SQL you can use the QUOTENAME() function to delimit your objects with [...]:
'USE ' + QUOTENAME('master', '[');
will give you
USE [master];
Off topic, the QUOTENAME() function has an interesting application as a protective measure against SQL injection. See for example,
http://msdn.microsoft.com/msdnmag/issues/06/11/sqlsecurity/default.aspx
__________________________________________________________________________________
SQL Server 2016 Columnstore Index Enhancements - System Views for Disk-Based Tables[/url]
Persisting SQL Server Index-Usage Statistics with MERGE[/url]
Turbocharge Your Database Maintenance With Service Broker: Part 2[/url]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply