Convert Composite Primary Key Into Simple Primary Key
Uma writes "Hi Dear,
I have A Table , Which Primary key consists of 6 columns.
total Number of Columns in the table are 16. Now i Want to Convert my Composite Primary key into simple primary key.there are already 2200 records in the table and no referential integrity (foriegn key ) exist.
may i convert Composite Primary key into simple primary key in thr table like this.
Thanks,
Uma"
View Complete Forum Thread with Replies
Related Forum Messages:
Composite Primary Keys Versus Composite Unique Indexes
Hello, I have a table which has a composite primary key consisting of four columns, one of them being a datetime called Day. The nice thing afaik with this composite key is that it prevents duplicate entries in the table for any given day. But the problem is probably two-fold 1. multiple columns need to be used for joins and I think this might degrade performance? 2. in client applications such as asp.net these primary keys must be sent in the query string and the query string becomes long and a little bit unmanagable. A possible solutions I'm thinking of is dropping the existing primary key and creating a new identity column and a composite unique index on the columns from the existing composite key. I would like to have some tips, recommendations and alternatives for what I should do in this case.
View Replies !
Composite Primary Key
i have a master table with around 15 columns and i am trying to findthe appropriate primary keys and indexes for the table.To make the records unique, i need to include two datetime columns (start and end dates ) and two integer columns ( attributes of therecord ) to make up a composite primary key. Both of these fourcolumns are found in the WHERE clause of my queries.Is it acceptable in the view of performance and how should i createthe indexes?
View Replies !
Composite Primary Key
Hello, Does composite primary key affect performance on the table that contains the composite primary key or tables that references this table? When composite primary key should be used?
View Replies !
Composite Primary Key Or Not?
This is really not a T_SQL question but there's no good category for it so I thought I'd just put it here. I have a table that will contain a large amoutn of data in one field, and every piece of this data is uniquely identitied by six other attributes, that is, six other fields (e.g. user_ID, type_ID, year, country, state, item_ID). I can either make these six fields into a composite primary key, or add an additonal field (say an identity column) as the primary key and add a unique constraint on these six fields. What are the pros and cons of both designs? The one data field is of nvarchar(2000) type and the table is likely to have 50 million+ rows in a couple of years of real use. This table is not referenced by any other tables so whatever the primary key is, there's no FK reference. However, there could be FK references to this table in the future. Does the FK possibility make a difference in the design considerations?
View Replies !
Creating Composite Primary Key
Hi I'm trying to create a composite Primary Key on a table. This is the SQL I've written: CREATE TABLE BookingItems ( BookingID INT NOT NULL REFERENCES Bookings(BookingID), EquipmentTypeID INT NOT NULL REFERENCES EquipmentType(EquipmentTypeID), CONSTRAINT PK_BookingItems_id PRIMARY KEY (BookingID, EquipmentTypeID) ) Is this right? I'm trying to define a Primary Key made up of BookingID and EquipmentTypesID, which are both Foreign Keys as defined in the column definition. Thanks Jon
View Replies !
Surrogate Or Composite Primary Key?
My previous post was not really clear, so I'll try again with a (hopefully) better (even if longer) example... Consider the following... A JOB describes the processment of a document. Each document can exist in two versions: English and French. A JOB can have 1 or 2 TASK, each describing the processement of either the English or French version. So we have the following: A: JOB (JobNum [PK], DocReference, StartDate, EndDate, ...) B: TASK (JobNum [PK] [FKa], Version [PK], Priority, ...) that is there is an identifying 1:M (where maxium allowed for M is 2) relationship between JOB and TASK; TASK being identified by JobNum and Version (where the domain for Version is {E, F}). Each TASK may require a TRANSLATION sub_task. Each TASK may require a TYPING sub_task. Each TASK may require a DISTRIBUTION sub_task. For example, for a given doc, the English TASK requires TRANSLATION and DISTRIBUTION, while the French only DISTRIBUTION. That is, there is a 1:1 not-required relationship between TASK and TRANSLATION, TYPING and DISTRIBUTION. So we have the following: A: JOB (JobNum [PK], DocReference, StartDate, EndDate, ...) B: TASK (JobNum [PK] [FKa], Version [PK], Priority, ...) C: TRANSLATION (JobNum [PK] [FKb], Version [PK] [FKb], DueDate, ...) D: TYPING (JobNum [PK] [FKb], Version [PK] [FKb], DueDate, ...) E: DISTRIBUTION (JobNum [PK] [FKb], Version [PK] [FKb], Copies, ...) As you can see I am using the PK of TASK as FK and PK for each of the three SUB_TASKs. To complicate things, each SUB_TASK has one or more assignments. The assignments for each SUB_TASK records different information from the others. So we have... A: JOB (JobNum [PK], DocReference, StartDate, EndDate, ...) B: TASK (JobNum [PK] [FKa], Version [PK], Priority, ...) C: TRANSLATION (JobNum [PK] [FKb], Version [PK] [FKb], DueDate, ...) D: TYPING (JobNum [PK] [FKb], Version [PK] [FKb], DueDate, ...) E: DISTRIBUTION (JobNum [PK] [FKb], Version [PK] [FKb], Copies, ...) F: TRA_ASSIGN (JobNum [PK] [FKc], Version [PK] [FKc], Index [PK], Translator, ...) G: TYP_ASSIGN (JobNum [PK] [FKd], Version [PK] [FKd], Index [PK], Typyst, ...) H: REP_ASSIGN (JobNum [PK] [FKe], Version [PK] [FKe], Index [PK], Pages, ...) that is there is an identifying 1:M relationship between each SUB_TASK and its ASSIGNMENTs, each ASSIGNMENT being identified by the SUB_TASK it belongs to and an Index. I wish I could send a pic of the ER diagram... Maybe there is another and better way to model this: if so, any suggestion? Given this model, should I use for TRANSLATION, TYPING and DISTRIBUTION a surrogate key, instead of using the composite key, like for example: C: TRANSLATION (TranslationID [PK], JobNum [FKb], Version [FKb], DueDate, ...) D: TYPING (TypingID [PK], JobNum [FKb], Version [FKb], DueDate, ...) E: DISTRIBUTION (DistributionID [PK], JobNum [FKb], Version [FKb], Copies, ...) this will "improve" the ASSIGNMENTs tables: F: TRA_ASSIGN (TranslationID [PK] [FKc], Index [PK], Translator, ...) G: TYP_ASSIGN (TypingID [PK] [FKd], Index [PK], Typyst, ...) H: REP_ASSIGN (DistributionID [PK] [FKe], Index [PK], Pages, ...) I could even go further using a surrogate key even for TASK, which leads me to the following: A: JOB (JobNum [PK], DocReference, StartDate, EndDate, ...) B: TASK (TaskID [PK], JobNum [FKa], Version , Priority, ...) C: TRANSLATION (TaskID [PK] [FKb], DueDate, ...) D: TYPING (TaskID [PK] [FKb], DueDate, ...) E: DISTRIBUTION (TaskID [PK] [FKb], Copies, ...) F: TRA_ASSIGN (TaskID [PK] [FKc], Index [PK], Translator, ...) G: TYP_ASSIGN (TaskID [PK] [FKd], Index [PK], Typyst, ...) H: REP_ASSIGN (TaskID [PK] [FKe], Index [PK], Pages, ...) I don't really like this second solution, but I'm still not sure about the first solution, the one with the surrogate key only in the SUB_TASks tables.
View Replies !
Composite Primary Key Constraint
Hi All, I have a table that has 3 columns, two of them make a composite primary key. The table is populated with data. What I need to do is to add a third column to a composite primary key. I have tried to do that with the following command: alter table databasesize add constraint pk_dbsize primary key (dbid) But I get the error message: Table 'databasesize' already has a primary key defined on it. How can I do this?
View Replies !
Composite Primary Keys
Newbie question... I have two tables (categories & listings) which create a many-to-many relationship. I have created an interim table with the primary keys from each table as a composite primary key...(cat_id & list_id). How does the interim table get populated with the id's? When I do an insert statement to insert data into the categories table, the cat_id field is automatically generated...same with the listings table, but when (and how) does the primary key data get into the interim table. Thanks in advance for the assistance.
View Replies !
Composite Primary Key Syntax
I'm trying this Code: CREATE TABLE Rating (ContentID int NOT NULL PRIMARY KEY REFERENCES Content_(ContentID), UserID int NOT NULL PRIMARY KEY REFERENCES Usr(UserID), rating tinyint DEFAULT 2, LastRead smalldatetime NOT NULL DEFAULT CURRENT_TIMESTAMP) And it is telling me this: Msg 8110, Level 16, State 0, Line 14 Cannot add multiple PRIMARY KEY constraints to table 'Rating'. So how do I combine two non-unique foreign keys, the combination of which is unique, into one primary key?
View Replies !
Composite Primary Key And Foreign Key
Hi, In my table1, I have a composite primary key ssn+firstname+lastname. In table2 I have ssn, firstname, lastname, col1. In table2 I want to create a foreign key which references table1 primary key? table1 and table2 has the primary, foreign key relationships. Still table2 need primary key. In table2 Can I make the ssn+Firstname+Lastname as primary key? or one column id as auto increment? Which is best way? Thanks
View Replies !
Composite Primary Key Autoincrement From 1
Hi, I'm currently writing a small application that is using SQL Server as a back-end database. A part of my database looks something lie the following: Tables: Orders(OrderId[int, PK], OrderDescription[varchar] etc...) OrderLines(OrderId[int, PK, FK], OrderLineId[int, PK], etc...) What I need to achieve is - everytime that a new line is inserted into an orderlines table part of the primary key will be the OrderId and the OrderLineId should be auto-incremented from 1 for each OrderId in the OrderLines table. I know i can do this manually in my program, but i'm just wondering if theres a way to achive this in SQL Server? Thanks, Nick Goloborodko
View Replies !
Composite Primary Key On A Table Variable?
Is is possible to create a composite primary key on a table variable?Neither of these two statements are successful:DECLARE @opmcjf TABLE (jobdetailid INT NOT NULL,cjfid INT NOT NULL,cjfvalue VARCHAR(100) NULL)ALTER TABLE @opmcjf ADD CONSTRAINT [PK_opmcjf] PRIMARY KEY CLUSTERED([jobdetailid],[cjfid])andDECLARE @opmcjf TABLE (jobdetailid INT PRIMARY KEY,cjfid INT PRIMARY KEY,cjfvalue VARCHAR(100) NULL)Thanks,Shaun
View Replies !
Referencing Composite Primary KEYS
Hi, i want to make a reference from a table on itself. The table has a composite Primary Key. But I just want to refernce the TEstCaseID. So whats wrong? Can anyone help me? CREATE TABLE dbo.TestCase ( Project_projectID VARCHAR(20) NOT NULL references Project, testCaseID VARCHAR(50) NOT NULL, PRIMARY KEY(Project_projectID, testCaseID), FatherID VARCHAR(50) references TestCase(testCaseID) ) THanx Crean
View Replies !
Composite Primary Key And Foreign Key - Relations
Hi, I have a doubt, can anyone please clarify me. I have created the following table, create table z ( eno int, deptno char(2), ename varchar(5), constraint pk_eno_deptno primary Key(eno,deptno) ) and I tried to establish a foreign key based on the above defined table. It's giving error, create table z_dup ( eno int FOREIGN KEY REFERENCES z(eno), deptno char(2) ) go Error:- ***** There are no primary or candidate keys in the referenced table 'z' that match the referencing column list in the foreign key 'FK__z_dup__eno__18CE1BA6'.Could not create constraint. See previous errors. Even I tried to create a foreign key like the following, create table z_dup ( eno int FOREIGN KEY REFERENCES z(eno,deptno), deptno char(2) ) go Error:- ******** More than one key specified in column level FOREIGN KEY constraint, table 'z_dup'. Can anyone please help me to create a foreign key relation with the base table. tks in advance, Srinivasan
View Replies !
Splitting A Composite Primary Key In A Table
NOTE: I am not interested in any responses that want to argue the use of a unique ID field and autonumbering as the PK. It is quite clear from the forums that this subject is a polarizing one. This question is for those who follow text-book design practices and believe that a composite primary key should be used when it is available. I want to be one of them for the time being. SYNOPSIS: I have three tables, TestSummary, TestDetails, and Steps. The TestSummary table looks like this: Create table TestSummary ( TestSummaryID int identity primary key, ... SequenceID int not null ) It contains the date and time of the test, the serial number, the part number, the test operator's name, and the ID of the sequence of steps used during the test. It uses a unique ID field for the primary key. The TestDetails table looks like this: Create table TestDetails ( TestDetailsID int identity primary key, TestSummaryID int not null, StepID int not null, ... ) It contains the details of the test like voltage readings, current readings, temperature, etc., one record per reading. It also contains the step number of the test sequence specified in the TestSummary table. The Steps table looks like this: Create table Steps ( SequenceID int not null, StepID int not null, Function int not null Primary key (SequenceID, StepID) ) It contains a list of all of the functions to be performed on the device under test by sequence number and the step number within the sequence. When I try to establish a relation between TestSummary.SequenceID and Steps.SequenceID, SQL Server flags an error because TestSummary.SequenceID and Steps.SequenceID:Steps.StepID do not match. What is the problem with this approach?
View Replies !
Insert Or Update SSIS For Composite Primary Key
Hi , We have scenario like this .the source table have composite primary key columns c1,c2,c3,c4.c5,c6 .when we move the records to destination .we have to check columns (c1+ c2 + c3 + c4 + c5 + c6) combination exist in the destination. if the combination exist then we should do a update else we need to do a Insert . how to achive this .we have tryed useing conditional split which is working only for a single Primary key . can any one help us . Jegan.T
View Replies !
How Do I Create A Composite Primary Key, Using Fields From Multiple Tables?
Hi All I hope someone smart can help me, it would be highly appriciated. I am developing an SQL Serverdatabase and in on of the tables I need the primary key to consist of two pieces of data. TblOrders: OrderNum, Orderdate, .... TblDispatchers: DispatcerID, Dispatcher, DispatcherAddress The OrderNum field in TblOrders need to be a composite of an AutoNum-field (incrementet by 1) and the DispatcerID from the tblDispatchers. Can this be done, and how. Many thanks Kind regards Tina
View Replies !
How To Find Missing Records From Tables Involving Composite Primary Keys
Table 1 Code Quarter 500002 26 500002 27 500002 28 500002 28.5 500002 29 Table 2 Code Qtr 500002 26 500002 27 I have these two identical tables with the columns CODE & Qtr being COMPOSITE PRIMARY KEYS Can anybody help me with how to compare the two tables to find the records not present in Table 2 That is i need this result Code Quarter 500002 28 500002 28.5 500002 29 I have come up with this solution select scrip_cd,Qtr,scrip_cd+Qtr from Table1 where scrip_cd+Qtr not in (select scrip_cd+qtr as 'con' from Table2) i need to know if there is some other way of doing the same Thanks in Advance Jacx
View Replies !
Composite Primary Key Using MS SQL Server Enterprise Manager &"Interface&"
I want to created composite primary key using MS SQL Server Enterprise Manager Interface. I want to use Interface instead of writing it in CREATE Table statement. I was able to create foreign key using this Interface using the "Manage Relationship" option. But cannot find how to add primary key consisting of two fields. Any help regarding this is highly appreciated.
View Replies !
Simple Question: ON PRIMARY?
Hi, Im really new to MS SQL - actually I just have a schema that I need to convert to Postgresql format. The MS SQL database already exists - I need to use a Postgresql web database to hold part of the master database's information. So, I've converted most of the "CREATE TABLE" schema, but right at the end it says: Code: ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO I have NO idea what the ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] bit means. Can someone please explain to me? And what part this would play in my Postgresql conversion? Ive been reading up a lot and find that the ON [PRIMARY] bit is pretty much standard with all tables, and TEXTIMAGE_ON [PRIMARY] is used a lot as well. But I'd just like to find out the meaning. So far I'm presuming I'd just have to delete that line since it doesn't apply to Postgresql. Am I right? Also, there was no primary key in the schema.. how does MS SQL identify the primary key for a table? I thought that every table needs at least one primary key ? Thanks a lot in advance!
View Replies !
Help With Simple Insert, How To Use Primary Key?
Ive added a primary key called ID to my table, now my insert stored procedure dont no longer work. i want an unique identifier for each row. heres my stored procedure: CREATE PROCEDURE composeMessage -- Add the parameters for the stored procedure here @username varchar(24), @sender varchar(24), @date dateTime, @subject varchar(255), @message varchar(2500) AS BEGIN insert into Messages( "Username", "Sender", "Date", "Subject", "Message" ) values ( @username, @sender, @date, @subject, @message ) END GO heres my sqlcreate table: USE [Messenger] GO /****** Object: Table [dbo].[Messages] Script Date: 09/12/2006 15:13:52 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Messages]( [Username] [varchar](24) COLLATE Latin1_General_CI_AS NOT NULL, [Sender] [varchar](24) COLLATE Latin1_General_CI_AS NOT NULL, [Subject] [varchar](255) COLLATE Latin1_General_CI_AS NOT NULL, [Message] [varchar](2500) COLLATE Latin1_General_CI_AS NOT NULL, [Date] [datetime] NOT NULL, [ID] [int] NOT NULL, CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF As primary keycan't be null, what do i put for primary key for my insert to work? hope you understand what i mean?
View Replies !
Auto Incremented Integer Primary Keys Vs Varchar Primary Keys
Hi, I have recently been looking at a database and wondered if anyone can tell me what the advantages are supporting a unique collumn, which can essentially be seen as the primary key, with an identity seed integer primary key. For example: id [unique integer auto incremented primary key - not null], ClientCode [unique index varchar - not null], name [varchar null], surname [varchar null] isn't it just better to use ClientCode as the primary key straight of because when one references the above table, it can be done easier with the ClientCode since you dont have to do a lookup on the ClientCode everytime. Regards Mike
View Replies !
Can We Pause Log Shipping, Bring Primary Db To Simple Recovery Model And Then Back To Full R Model?
We have the following scenario, We have our Production server having database on which Few DTS packages execute every night. Most of them have Bulk Insert stored procedures running. SO we have to set Recovery Model of the database to simple for that period of time, otherwise it will blow up our logs. Is there any way we can set up log shipping between our production and standby server, but pause it for some time, set recovery model of primary db to simple, execute DTS Bulk Insert Jobs, Bring it Back to Full recovery Model AND finally bring back Log SHipping. It it possible, if yes how can we achieve this. If not what could be another DR solution in this scenario. Thanks Much Tejinder
View Replies !
4 Key Primary Key Vs 1 Key 'artificial' Primary Key
Hi all I have the following table CREATE TABLE [dbo].[property_instance] ( [property_instance_id] [int] IDENTITY (1, 1) NOT NULL , [application_id] [int] NOT NULL , [owner_id] [nvarchar] (100) NOT NULL , [property_id] [int] NOT NULL , [owner_type_id] [int] NOT NULL , [property_value] [ntext] NOT NULL , [date_created] [datetime] NOT NULL , [date_modified] [datetime] NULL ) I have created an 'artificial' primary key, property_instance_id. The 'true' primary key is application_id, owner_id, property_id and owner_type_id In this specific instance - property_instance_id will never be a foreign key into another table - queries will generally use application_id, owner_id, property_id and owner_type_id in the WHERE clause when searching for a particular row - Once inserted, none of the application_id, owner_id, property_id or owner_type_id columns will ever be modified I generally like to create artificial primary keys whenever the primary key would otherwise consist of more than 2 columns. What do people think the advantages and disadvantages of each technique are? Do you recommend I go with the existing model, or should I remove the artificial primary key column and just go with a 4 column primary key for this table? Thanks Matt
View Replies !
SIMPLE Command To Convert String To Number? Not CAST Or CONVERT.
Dear Experts,Ok, I hate to ask such a seemingly dumb question, but I'vealready spent far too much time on this. More that Iwould care to admit.In Sql server, how do I simply change a character into a number??????In Oracle, it is:select to_number(20.55)from dualTO_NUMBER(20.55)----------------20.55And we are on with our lives.In sql server, using the Northwinds database:SELECTr.regionid,STR(r.regionid,7,2) as a_string,CONVERT(numeric, STR(r.regionid,7,2)) as a_number,cast ( STR(r.regionid) as int ) as cast_to_numberFROM REGION R1 1.00112 2.00223 3.00334 4.0044SELECTr.regionid,STR(r.regionid,7,2) as a_string,CONVERT(numeric, STR(r.regionid,7,2) ) as a_number,cast (STR(r.regionid,7,2) as numeric ) as cast_to_numberFROM REGION R1 1.00112 2.00223 3.00334 4.0044Str converts from number to string in one motion.Isn't there a simple function in Sql Server to convertfrom string to number?What is the secret?Thanks
View Replies !
Primary Key
Hi.. I'm going to build database of university, but I have problem with primaru key, This is the situation: there are many faculities and each one has many departments, each department has many courses, each course has many sections.. The problem: I want to make those fields in the same table and make the primary key generate from other fields, (i.e) I want the faculity be integer from 4 digit "Example the first faculity start with 1000 the second 2000 and so on" and the the department of each faculity will generate its value from the faculity number+interger number from 3digit "Example the department of the first faculity start with 1100 and the second on will be 1200 and so on " the same thing will repeate for courses and sections so the sectionsID will be the primary key. Do you know hoew this idea can be implement by SQL server 2005? Please help me as soon as possible.
View Replies !
Primary Key
I have a Department Table. Can any one tell me its Primary Key. I have the order AutoNumber, D + AutoNumber, Code, Can you help me regarding this. Because some people never like to use AutoNumber. That's why I am confused.
View Replies !
Primary Key
Hello all,I'm taking over a project from another developer and i've run into a bit of a problem. This developer had a bad habit of not using primary keys when designing various databases used by his programs. So now i've got approx 1000 tables all of which do not have primary keys assigned. Does anyone know of a tsql script that i can run that will loop through each table and add a primary key field?Thanks in advance?Richard M.
View Replies !
Primary ID = BC
A column will be Primary Key. Others are B and C. I want A will contain B and C. I mean B data is X, C data is Y, A will be XY. How can i do this? Can i set in MSSQL or need ASP.NET?
View Replies !
Primary Key
Hi,Can someone give me advice ( or link to a webpage ) about how can I useprimary key in my database and how can I use it for optimizing thespeed of my database.Thanks.
View Replies !
Primary Key Not Set
Hi,I have copied a table structure with 13 rows from one db to other dbafter executing.. sp_dboption nowdb,'select * into/bcp',true.. select * into newtab from d1.dbo.oldtabThe table is copied but the primary key is not unlike the oldtab hasthe pk.could you please tell the way to insert the primary key,using tsqlwhile coping the needed table from source to destination.with regardsRaghu
View Replies !
How Can You Tell What The Primary Key Of A New Row Will Be?
I need to insert a row into a table in SQL Server 2000. The primarykey for the row is an identity type, so it auto-numbers for me withoutneeding to put in the value in the insert statement.My problem, is that after i insert a row, i need to insert another rowin a different table that references the first row. To do that i needto know the primary key for the original row.How can i tell what the primary key was? In Oracle, you would checkthe sequence before the original insert. Is there a similar featurein SQL Server? And how would you use it?(I'm using C# ADO)- Paul
View Replies !
DTS Is Not Getting The Primary Key
Hi All, Using DTS i have imported the data from sybase to MS SQL server and all the data and tables were imported correctly.But the primary keys are not marked why is it like this? This is not a one time job and this is meant to be for the customers also.I cannot ask the customers to mark the primary keys themselves. Is there a way to get the keys also.While doing DTS I have marked all the options correctly. Please help.
View Replies !
Primary Key
I am setting up some tables where I used to have an identity column as the primary key. I changed it so the primary key is not a char field length of 20. Is there going to be a big performance hit for this? I didn't like the identity field because every time I referenced a table I had to do a join to get the name of object. EG: -- Old way tbProductionLabour ID (pk)| Descr | fkCostCode ---------------------- 1 | REBAR | 1J tbTemplateLabour fkTemplateID | fkLabourID | Manpower | Hours -------------------------------------------- 1 | 1 | 1 | 0.15 -- New way tbProductionLabour Labour | fkCostCode --------------------- REBAR | 1J tbTemplateLabour fkTemplateID | fkLabour | Manpower | Hours ------------------------------------------- 1 | REBAR | 1 | 0.15 This is a very basic example, but you get the idea of what I am referring to. Any thoughts? Mike
View Replies !
Primary Key
I need to create my own primary key, how do I go about doing that?? In the database I am working in usually has a primary key that looks like this VL0008 the V is for Vendors, thats basically their number. Some of these Vendors need to be licensed and some dont, the ones that are not licensed dont get a number but I am to use that as the Primary/Index key I need to create one for those particual vendors. How can I go about doing that??? I was wanting to make it TL888 something like that.
View Replies !
How To Get Primary Key....plz Help!!!!
i'm having problem to get th primary key from d database.... for your information i'm using java to get the primary key.... this is my code... rs = stt.executeQuery("sp_columns "+table_db+";"); while(rs.next()) { out.write(""+rs.getString("COLUMN_NAME")); out.write(", "+rs.getString("TYPE_NAME")); out.write(", "+rs.getString("IS_NULLABLE")); } rs = stt.executeQuery("sp_foreignkeys @table_name = N'table_db';"); but the problem is.... i get this error message...could anyone tell me what's the problem.... java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find server 'table_db' in sysservers. Execute sp_addlinkedserver to add th e server to sysservers. how do i solve this problem.... thanx to anyone who can help me...... :D
View Replies !
Primary Key
Please help: I am creating a table called Bonus: ProductHeading1 ProductHeading2 (could be null) ProductHeading3(could be null) Bonus Datefrom DateTo .... what would be the primary key?! I know it would be DateTo and sumfing...... Since Heading2 and Heading3 could be null, they cannot be PK... and heading1 cannot be a PK because the following three DIFFERENT options could have the same heading1 Option 1) heading1 = "X" heading2 = Null heading3 = Null Option 2) heading1 = "X" heading2 = "Y" heading3 = Null Option 3) heading1 = "X" heading2 = "Y" heading3 = "Z" ... but I need a PK to make sure a bonus is not entered twice... I considered added an Id, but them how do I assign a id?! what would i make the id equal to??? Thanks....
View Replies !
Primary Key
In a recent course on database programming using Microsoft Access 2002. I noticed that the text entitiled New Perspectives Microsoft Access 2002 stated that a primary key could only be used once per table. But If I am not mistaken could one use the select key to select more than one primary key within a table.
View Replies !
Primary Key
Heya, I'm trying to setup a Primary Key on a SQL 6.5 database. Is there a way to do this? When I hit advanced, it asks for me to select a field for the primary key, but it doesnt list fields to selct from, and I cant type it in. Thanks for your help,
View Replies !
Primary Key
Hi, In sqlserver table I put the ssn+firstname+lastname combination as the primary key, due to this ssn, firstname, lastname fields are constrained as NOT NULL. I am importing from Excel to this table. In Excel file SSN contains some Nulls, firstname contain some Nulls for some records. So I am using Sort transformation to remove duplicate records and applied sort on ssn, firstname, lastname. but I am getting integrity constraint violated error in SSIS, whether it is due to when inserting Null into SSN but it is constrained as NotNull. or it check the combination of ssn,firstname, lastname? If it checks the combination of ssn,firstname,lastname all are nulls this row inserted, next if this combination agin occurs sort transformation delete them? Why I amgetting ssn violation error? Thanks
View Replies !
|