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!
There is no need to use [] when you are querying your data form the database.
you use [] when there is space of alias name like
because it gives syntax error
dbo is the schema name that with which your table and the user attached
here is more detail answer
A database schema is a way to logically group objects such as tables, views, stored procedures etc. Think of a schema as a container of objects.
You can assign a user login permissions to a single schema so that the user can only access the objects they are authorized to access.
Schemas can be created and altered in a database, and users can be granted access to a schema. A schema can be owned by any user, and schema ownership is transferable.
You can also read full article on : http://www.quackit.com/sql_server/sql_server_2008/tutorial/sql_server_database_schemas.cfm