Monday, March 26, 2012

primay key

How do you assign a primary key to a column in SQL 2005? Thanks.
Hi
CREATE TABLE dbo.Test (c INT NOT NULL PRIMARY KEY)
"00KobeBrian" <a@.b.com> wrote in message
news:eVQgpKz8GHA.2248@.TK2MSFTNGP04.phx.gbl...
> How do you assign a primary key to a column in SQL 2005? Thanks.
>
|||00KobeBrian wrote:
> How do you assign a primary key to a column in SQL 2005? Thanks.
ALTER TABLE tbl ADD CONSTRAINT tbl_pk PRIMARY KEY (col);
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
|||Sorry. How do you do that in SQL Server Management Studio?
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1161239072.297334.114770@.b28g2000cwb.googlegr oups.com...
> 00KobeBrian wrote:
> ALTER TABLE tbl ADD CONSTRAINT tbl_pk PRIMARY KEY (col);
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>
|||On Oct 19, 11:48 am, "00KobeBrian" <a...@.b.com> wrote:[vbcol=seagreen]
> Sorry. How do you do that in SQL Server Management Studio?
> "David Portas" <REMOVE_BEFORE_REPLYING_dpor...@.acm.org> wrote in messagenews:1161239072.297334.114770@.b28g2000cwb.g ooglegroups.com...
>
>
>
right click on table - select modify table.
select column you want to set as primary key and right click and select
option to set primary key
Regards
Amish Shah
http://shahamishm.tripod.com
|||Can anyone please help?
"00KobeBrian" <a@.b.com> wrote in message
news:%23w0gVq08GHA.788@.TK2MSFTNGP05.phx.gbl...
> Sorry. How do you do that in SQL Server Management Studio?
>
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> news:1161239072.297334.114770@.b28g2000cwb.googlegr oups.com...
>
|||I mean like SQL 2000. All I do is open up the Enterprise Manager and click
the key icon in the top to the column of a table and then the primary index
get assigned. How can I do it similiarly in SQL 2005? There got to be a way,
right? Thanks.
"00KobeBrian" <a@.b.com> wrote in message
news:%23w0gVq08GHA.788@.TK2MSFTNGP05.phx.gbl...
> Sorry. How do you do that in SQL Server Management Studio?
>
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> news:1161239072.297334.114770@.b28g2000cwb.googlegr oups.com...
>
|||Right click mouse on the column...
"00KobeBrian" <a@.b.com> wrote in message
news:e4leM28AHHA.3316@.TK2MSFTNGP02.phx.gbl...
>I mean like SQL 2000. All I do is open up the Enterprise Manager and click
>the key icon in the top to the column of a table and then the primary index
>get assigned. How can I do it similiarly in SQL 2005? There got to be a
>way, right? Thanks.
>
> "00KobeBrian" <a@.b.com> wrote in message
> news:%23w0gVq08GHA.788@.TK2MSFTNGP05.phx.gbl...
>
|||00KobeBrian wrote:
> I mean like SQL 2000. All I do is open up the Enterprise Manager and click
> the key icon in the top to the column of a table and then the primary index
> get assigned. How can I do it similiarly in SQL 2005? There got to be a way,
> right? Thanks.
>
On Server Management Studio, create the table and right click on the
left one column. Select "Set Primary Key" from the popup menu.
Arto Viitanen, CSC Ltd.
Espoo, Finland
|||Hi Guys,
I cannot find "Set Primary Key" from the popup menu. It only has
new column, modify, rename, delete, refresh and properties. In properties
page, the primary key field is grey out. I cannot change from no to yes.
Please help. Thanks.
"Arto Viitanen" <arto.viitanen@.csc.fi> wrote in message
news:4552da27$0$8957$ba624cd0@.newsread.funet.fi...
> 00KobeBrian wrote:
> On Server Management Studio, create the table and right click on the
> left one column. Select "Set Primary Key" from the popup menu.
> --
> Arto Viitanen, CSC Ltd.
> Espoo, Finland

No comments:

Post a Comment