Wrox Programmer Forums
|
BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6
This is the forum to discuss the Wrox book Beginning SQL Server 2005 Programming by Robert Vieira; ISBN: 9780764584336
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2007, 06:30 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to combine fields into a PK - Need urgent help

Hello World ;)

I've found great help in many WROX forums, so I hope you will all help me again. I really appreciate your efforts and knowledge.

I have 3 tables, and in one of the tables I need to have the PK be composed of a FK from an other table and a value that is incremented by one.

tblSite:
    SiteID, nvarchar(4)
    SiteName nvarchar(30)

tblOrder
    OrderID smallint
    OrderDate smalldatetime
    SiteID nvarchar(4)
...
...
...

tblOrderRequisition
    OrderRegID smallint
    OrderID smallint
    ReqID smallint

tblRequisition
    ReqID smallint
    ItemID smallint
...
...
...

Obviously these tables are related, now my question is:
Can I change my database so that the ReqID can be a composite of SiteID and a value that is incremented by one for each record in the tblRequisition? And how do I do that?

I'm somewhat experienced in Access, and here I would have used a lookup, but how do you perform a cross table lookup in SQL Server 2005?

Please be very specific in your reply, I am as mentioned a little new to designing SQL Server 2005 databases.

Again thanks in advance for your help.

Kind regards
Tina Nielsen
Denmark


Kind regards
Tina Nielsen, Denmark





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine fields>Runtime error 2450 Chris333 Access VBA 4 July 6th, 2007 07:10 AM
Need help! Setting PK value at runtime! Darrell86 SQL Server 2005 6 November 20th, 2006 01:33 AM
Access ADOX - delete PK Derek_05 Access VBA 7 January 4th, 2006 03:32 AM
Null Fields - Urgent narooma.12 Crystal Reports 0 October 24th, 2004 05:32 PM
PK problem reindeerw Access 10 April 15th, 2004 01:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.