选择主键
[更新:MS SQL Server 2005]
您好,是否可以选择一堆值,然后在 select 语句中指定一列作为主键?
SELECT ID FROM HQ AS PRIMARYKEY -- this is wrong
SELECT Names FROM Stores
SELECT PRODUCTNAME FROM PRODUCTS
我问这个是因为我想利用.net中的DataRow find方法,谢谢。
[UPDATE: MS SQL Server 2005]
Hi is it possible to select a bunch of values, and then assign a column in the select statement as the primary key?
SELECT ID FROM HQ AS PRIMARYKEY -- this is wrong
SELECT Names FROM Stores
SELECT PRODUCTNAME FROM PRODUCTS
I ask this because I want to take advantage of the DataRow find method in .net, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
填充数据集后,您必须使用 DataTable 对象指定主键,而不是在 sql 查询中指定主键。
然后你可以使用Find()方法
After populating your dataset, you have to specify the primary key with the DataTable object, not in your sql query.
Then you can use the Find() method
不,我不认为你可以做到这一点,即让 SQL Server 将准备好的索引传递给 .NET 应用程序。 您可以向 DataTable 添加一个索引来保存数据,它将在客户端构建。
No I don't think you can do that, that is have SQL server pass a ready index to the .NET app. You can add an index to the DataTable which will hold the data, it will be build on the client side.