none
how to make composite primary key

    Question

  • I am pursuing my B.Tech. i m busy in my project on asp.net using c#. i used sql server 2000. i m trying to make the project named "Student database". i do not know how to make composite primary key. can some one send me the way of making composite primary key. i want roll no., class name and year colloum act as composite primary key

     

    Thursday, March 06, 2008 3:02 PM

Answers

  • If you are using SQL Server 2005 Management Studio to connect to your SQL Server 2000 database, just right click on your table in Object Explorer and select Design. Then select all the columns you would want to form the primary key (hold Ctrl key for multi selection), right click on the selection and choose "Set Primary Key"

     

    Thursday, March 06, 2008 7:28 PM
  • On the other hand, if you are asking about how to do this in the Visual Studio DataSet designer, the procedure is basically the same:

     

    1.  Highlight both of the columns in your DataTable.  You can SHIFT or CTRL click. 

    2.  Click the Data, Set Primary Key menu command.

    3.  A yellow "key" icon should now appear to the left of both columns.

     

    Note that there are separate forums for both SQL Server and .NET data access.  It would have been preferable had you posted to one of those two forums as appropriate.

     

    ADO.Net DataSet Forum -- http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=2034&SiteID=1

    SQL Server Tools General -- http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=84&SiteID=1

     

     

     

    Friday, March 07, 2008 12:10 AM

All replies

  • If you are using SQL Server 2005 Management Studio to connect to your SQL Server 2000 database, just right click on your table in Object Explorer and select Design. Then select all the columns you would want to form the primary key (hold Ctrl key for multi selection), right click on the selection and choose "Set Primary Key"

     

    Thursday, March 06, 2008 7:28 PM
  • On the other hand, if you are asking about how to do this in the Visual Studio DataSet designer, the procedure is basically the same:

     

    1.  Highlight both of the columns in your DataTable.  You can SHIFT or CTRL click. 

    2.  Click the Data, Set Primary Key menu command.

    3.  A yellow "key" icon should now appear to the left of both columns.

     

    Note that there are separate forums for both SQL Server and .NET data access.  It would have been preferable had you posted to one of those two forums as appropriate.

     

    ADO.Net DataSet Forum -- http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=2034&SiteID=1

    SQL Server Tools General -- http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=84&SiteID=1

     

     

     

    Friday, March 07, 2008 12:10 AM