日期:2010-04-07 浏览次数:20517 次
园子里关于存储过程的讨论有很多,不少人建议将SQL语句写在程序中,这篇随笔讨论一下SQL语句在程序中的写法。
1string strSQL = "SELECT [AddressID], [AddressLine1], [AddressLine2], [City], [StateProvinceID], [PostalCode], [rowguid], [ModifiedDate] FROM [AdventureWorks].[Person].[Address] WHERE City = 'Bothell' ORDER BY AddressID";
这是最普通的一种写法,而且在开发中被广泛采用。
string strSQL = "SELECT " +
"[AddressID], " +
"[AddressLine1], " +
"[AddressLine2], " +
"[City], " +
"[StateProvinceID], " +
"[PostalCode], " +
"[rowguid], " +
"[ModifiedDate] " +
"FROM " +
"[AdventureWorks].[Person].[Address] " +
"WHERE " +
"City = 'Bothell' " +
"ORDER BY " +