Friday, March 23, 2012

Primary Keys

I have managed to confuse myself as to when and how you can set up Primary
Keys on an MSDE database.
Are Primary Keys only used when you are connected to an MS Access project or
can they be used in other places.
I come from an MS Access background and am familure with the use of Primary
Keys my problem is that I cannot seem to turn them on. I already have a
clustered index set up on the table and am using Identidy to declare a field
as unique. Could this be the reason why I cannot turn on the Primary Key
option?
Any insight would be useful.
Thanks
June
> Keys my problem is that I cannot seem to turn them on.
What does this mean? How are you trying to "turn them on"? What tool are
you using, and are you using ALTER TABLE or clicking buttons in a GUI? Are
you getting an error message? If so, what is it?
http://www.aspfaq.com/
(Reverse address to reply.)
|||I have tried using Andrea Montanari's DbaMGR2k and Microsoft Web Data
Administrator.
Using DbaMGR2k - When logged on as dbo I cannot check the checkbox beside
Primary Key although I can change all the other field settings. There is no
message, simply nothing happens.
Using Microsoft Web Data - when editing a table I can set the Primary Key
only on tables that have no rows of data in them. As soon as there is data
in the table the option to edit the fields is removed.
I want to be able to set up Primary Keys and Foreign Keys in order to set up
a relationship. I also want my tables to have a clustered index which in
most, but not all, cases will be the same field as the Primary Key.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:OraGgF%23cEHA.3512@.TK2MSFTNGP12.phx.gbl...
> What does this mean? How are you trying to "turn them on"? What tool are
> you using, and are you using ALTER TABLE or clicking buttons in a GUI?
Are
> you getting an error message? If so, what is it?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
|||If you can use osql or isql to connect to MSDE, you can issue an ALTER TABLE
/ ADD CONSTRAINT command, which isn't limited by what an application thinks
you should/shouldn't be able to do. Barring that, you can create a dummy
table with the primary key intact, copy the data over, drop the old table,
and rename the new table. If these tools will let you do those things too,
of course.
http://www.aspfaq.com/
(Reverse address to reply.)
"June Macleod" <junework@.hotmail.com> wrote in message
news:#xwOW39cEHA.1652@.TK2MSFTNGP09.phx.gbl...
> I have managed to confuse myself as to when and how you can set up Primary
> Keys on an MSDE database.
> Are Primary Keys only used when you are connected to an MS Access project
or
> can they be used in other places.
> I come from an MS Access background and am familure with the use of
Primary
> Keys my problem is that I cannot seem to turn them on. I already have a
> clustered index set up on the table and am using Identidy to declare a
field
> as unique. Could this be the reason why I cannot turn on the Primary Key
> option?
> Any insight would be useful.
> Thanks
> June
>
|||hi June,
"June Macleod" <junework@.hotmail.com> ha scritto nel messaggio
news:eKX7Vb%23cEHA.1644@.tk2msftngp13.phx.gbl...
> I have tried using Andrea Montanari's DbaMGR2k and Microsoft Web Data
> Administrator.
> Using DbaMGR2k - When logged on as dbo I cannot check the checkbox beside
> Primary Key although I can change all the other field settings. There is
no
> message, simply nothing happens.
as regard DbaMgr2k, the help file specifies the Primary Key can not be set
in the "Table Management" window, where the check is read only, but in the
Indexes/Keys/Check window =;-D
so you have to access that window, both for PKs and indexes management as
for Foreign Keys management, as DbaMgr2k does not implement Diagrams
management [ =:-( , I know ]

> Using Microsoft Web Data - when editing a table I can set the Primary Key
> only on tables that have no rows of data in them. As soon as there is
data
> in the table the option to edit the fields is removed.
yes, you are right... WDA will not allow you to edit existing columns when
the base table is populated (sqlwish@.microsoft.com =;-D )

> I want to be able to set up Primary Keys and Foreign Keys in order to set
up
> a relationship. I also want my tables to have a clustered index which in
> most, but not all, cases will be the same field as the Primary Key.
and you can do it... with WDA you have to resort on executing Transact-SQL
statements, becouse it only supports PK setting (AFAIK)... with my tool you
can do it both graphically (but not in the Table Management window =;-D)
and/or performing Transact-SQL statements execution...
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.8.0 - DbaMgr ver 0.54.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||> as regard DbaMgr2k, the help file specifies the Primary Key can not be set
> in the "Table Management" window, where the check is read only, but in the
> Indexes/Keys/Check window =;-D
> so you have to access that window, both for PKs and indexes management as
> for Foreign Keys management, as DbaMgr2k does not implement Diagrams
> management [ =:-( , I know ]
>
Thank you, that works
June

No comments:

Post a Comment