How to quote and reference MS SQL table and field names
Posted
by artvolk
on Stack Overflow
See other posts from Stack Overflow
or by artvolk
Published on 2010-05-11T18:51:00Z
Indexed on
2010/05/11
18:54 UTC
Read the original article
Hit count: 278
Good day!
Despite the fact LINQ2SQL and ADO.NET Entity Framework exists there were situations when I need to revert to plain old DataSet (not typed) and friends.
While writing SQL for SqlCommand:
- Is it needed to quote field and table names with []?
- Is it good to prefix table names with [dbo]
I use to use this syntax:
SqlCommand command = new SqlCommand("SELECT [Field1], [Field2] FROM [dbo].[TableName]", connection);
May be there is a better way?
Thanks in advance!
© Stack Overflow or respective owner