tags:

views:

161

answers:

2

[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.

+2  A: 

After populating your dataset, you have to specify the primary key with the DataTable object, not in your sql query.

myTable.PrimaryKey = new DataColumn[] {
    myTable.Columns["SomeColumn"]
};

Then you can use the Find() method

BC
What I was looking for, thank you.
Oliver S
A: 

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.

Serguei