One person more books

Hi all,
help me please :-) I want to create one table Person and one table Books ... so one Person can has more books ... how to create this database model? And also important question for me is how to insert data to this model ... for eample:
insert one person and three books  thanks

You have to use SCOPE_IDENTITY to get the last inserted IDENTITY value:
use tempdb;
go
create table person(
id int not null identity(1,1) primary key,
name varchar(50),
modified_date datetime default (CURRENT_TIMESTAMP)
create table books(
id_book int not null identity primary key,
id_person int,
title varchar(250),
modified_date datetime default (CURRENT_TIMESTAMP)
go
declare @bb as INT;
insert into person (name) values ('John');
set @bb = SCOPE_IDENTITY();
insert into books (id_person,title) values (@bb,'The story of my life');
go
select * from person; select * from books;
go
id name modified_date
1 John 2014-06-23 08:49:27.170
id_book id_person title modified_date
1 1 The story of my life 2014-06-23 08:49:27.170
The other way is to use the OUTPUT clause:
http://www.sqlusa.com/bestpractices2005/outputidentitycapture/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

Similar Messages

  • Events - adding more than one person

    Hi there guys, I'm sure there's a simple answer to this:
    I've created an event.
    I've got a limit of 20 people.
    I have a web form associated with that event.
    On the form - how can I allow one person to book e.g. 2 or 3 people into that event? I don't need specifics like emails etc for the 2nd & third person. Just the "numbers" to be linked to the event.
    So if I've got 20 people able to attend, and one person wants to book themselves & 2 others, the event will be updated with "17 places left".
    Any info most appreciated...
    Cheers
    Dave

    You need to ajax submit multiple times to account for the extra submissions Dave.

  • HT1277 I have OS X 10.9.2 and have downloaded maverick. If I am sending an email message to one person, options for addresses  from my address book show up. However if I want to send it to more than one person, the address options for the others do not sh

    I have OS X 10.9.2. and have downloaded Maverick. If I am sending an email message to one person, options for addresses from my Address Book appear. However if I want to send it to more than one person, the potential addresses for the other persons do not show. Can you please help?

    Install ClamXav and run a scan with that. It should pick up any trojans.   
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101

  • I have a mac book pro and when I turned on iChat it would not let me video chat with more then one person even though I was able to in the past. It only showed an icon to video chat with one person. Please help!!

    I have a mac book pro and when I turned on iChat it would not let me video chat with more then one person even though I was able to in the past. It only showed an icon to video chat with one person. Please help!!!! ASAP

    Hi,
    Check the iChat Menu > Preferences > Video Section > Bandwidth setting.
    iChat needs to see a Minimum of 128kbps to do 1-1 chats in Video
    For 3 and 4 way chats it needs 384kbps
    Set the Bandwidth to 500kbps if it is set lower.
    Also check the speed you are getting from your Internet supplier.
    9:28 PM      Thursday; February 23, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • I am unable to send emails to more than one person in the to: on my emails

    I seem to be unable to send an email to more than one person at a time.  can do on i pad and i phone but not on mac book pro. any advice? If I want to do two people i can do one in the to: and one in the copy:. 

    Ok, now, typically, it's mysteriously working. No idea if what I was doing caused it. Set up the account as a POP one using my work outgoing server instead of mail.me.com, discovered that the phone automatically removed all my outgoing mail servers, right after I'd activated them all, so went back and reactivated. Sent email successfully. Created another account as IMAP but everything else the same, and now it suddenly works.
    This has happened to me several times in the past.

  • How do I broadcast a wedding to more than one person?

    How can I broadcast a wedding to more than one person at a time?

    I missed your 2nd question.
    This article explains how to always show remote content and the risks of doing so. You can make that call. Adding your trusted senders to your address book will allow content from them and is the recommended action.
    http://kb.mozillazine.org/Privacy_basics_(Thunderbird)

  • Addressing to more than one person

    How can I address an email to more than one person?
    feel frustrated to have to ask such a dummm question!

    I'm assuming that you are using Mail.app and not talking about using .mac mail or other mailserver via a web browser like Safari. If you are using the Mail client program, continue on, otherwise, never mind.
    If you don't already have an address book icon in your new message composition window (with that window being the active window (i.e., you clicked your mouse in it)), then...
    ...on the Menubar, go under View and select Customize Toolbar....
    Drag the AddressBook icon into the toolbar region of your new message composition window.
    This will provide you with the shortcut tool that I think you are seeking, to view and select names/email addresses stored in your local Address Book, from within the Mail application itself.
    You may need to repeat this process for the Reply, Reply All, Forward, and Redirect message composition windows, as well.
    (if this solves your problem, or is actually helpful towards arriving at a solution to your problem, please consider marking this reply as "helpful" or "solved," in addition to, if applicable, marking this question as "answered")

  • One person in my contact book cannot receive texts anymore. Suggestions?

    Hi,
    One person in my contact book (a non-iphone user) cannot receive text messages anymore. Any suggestions? The only thing done different is my nice did try to face-to-face them (by mistake). I delated the call attempt, delated the text history, even delated and re-installed the contact information. HELP!!

    Hello laurenblairf,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/ts2755
    To resolve issues with sending and receiving MMS, follow these steps
    Go to Settings and turn airplane mode off.
    Go to Settings > Messages and turn MMS Messaging on.
    Go to Settings > Cellular and turn Cellular Data on.
    Go to Settings > Cellular and turn Data Roaming on if you're roaming on a cellular provider network that is different from your billing provider's network.
    Make sure that you have a cellular data connection in the status bar of your iPhone.
    Go to Settings and turn Wi-Fi off. Open Safari and navigate to www.apple.com to verify that you have a data connection. Turn Wi-Fi back on to continue using Wi-Fi for other features. If your cellular data connection isn't available, follow these steps.
    Make sure that you can send and receive SMS. If you can't send and receive SMS, see the "Issues with sending and receiving SMS" section, above. MMS might not be available while you're on a call. Only 3G and faster GSM networks support simultaneous data and voice calls. Learn more about which network your phone supports.
    Restart your iPhone.
    Tap Settings > General > Reset > Reset Network Settings on your iPhone.
    Remove your SIM card and insert it again.
    Have a nice day,
    Mario

  • HT201317 can more than one person post photos to a shared photo stream?

    can more than one person post photos to a shared photo stream?

    No.  At the present time, only the person creating the shared photo stream can add or delete photos.

  • HT201077 Can more than one person upload photos to the shared Photo Stream?

    Is there any way that more than one person can stream their photo on the same Photo Stream Album?

    That's just the way it is right now.  But if you would like to see this changed you can tell Apple here: http://www.apple.com/feedback/icloud.html.

  • How to pixalet more than one person on the same piece of footage?

    Trying to pixalet more than one person in a piece of video footage with Final Cut Pro X. Having problems trying to do more than one person.

    rebelrider1 wrote:
    Trying to pixalet more than one person…
    you can apply the Censor Effect, as most other effects, more than once:

  • Forwarding messages to more than one person at a time, how in the heck do i do it ??

    I recently got a new phone, and am trying to learn how to send messages to more than one person at a time. It is a Samsung Gem. 
    Thanks so much people,
    Gayle

    Gayle1963 wrote:
    I recently got a new phone, and am trying to learn how to send messages to more than one person at a time. It is a Samsung Gem. 
    Thanks so much people,
    Gayle
    Hi there!
    I hope you are enjoying your new phone.
    In order to forward a text message to multiple people, just long-press on the message you want to send and select 'Forward'. In the 'To:' field begin typing the first persons name, then hit the 'enter' key. This will typically move the cursor down to the message, just tap on the 'To:' field again and begin typing the second person's name, and so on and so forth until you get all the people included.
    Keep in mind, if you have a limited texting package that sent messages are billed per recipient. Example, if you forward a text to 10 people, then 10 messages go against the allowance.
    Have a great day!

  • When texting with more than one person at a time the incoming text scrolls to top of the conversation. anyone out there with the same issue?

    while texting with more than one person at a time the incoming texts scrolls to top of conversation. anyone having this issue?

    I've heard claims it can be done, claims some have done it, and claims that it didn't work for them. This thread is interesting, some indications it should be possible, complaints that it didn't, and also an interesting work-around:
    "How do I text message multiple people at once?"
    http://discussions.apple.com/click.jspa?searchID=-1&messageID=4822260
    You can ask Apple for iPhone changes via this link:
    http://www.apple.com/feedback/iphone.html
    Though if you're requesting hardware changes for iPhone v2 you may want to wait a week (or a month?)...they're probably going to be inundated right now by requests for software changes to the current iPhone.
    (If this has answered your question, please mark your original post as answered)

  • How do people register for more than one person on a form?

    We had a lot of complaints last year from organizations who sent several employees to our training.  It took a long time for them to process these one at a time.  How do people register for more than one person on a form?

    Hi thearcca,
    This entirely depends on the form you create, you can add multiple choice button and ask for the no. of employees the organization wants to register.
    Also, you can add corresponding text field for the names.
    Thanks,
    Vikrantt Singh

  • How do I send, or bcc to more than one person at a time?

    I have used outlook express for years and grown very familiar with it. I switched to Thunderbird because of mail problems in WIN7. I have no problem receiving, or sending to one person. The email autofills the name of the first person, but when I try to type another name, the first is deleted. This is the same on TO: or BCC. Also, is there a way to avoid having to click on the field "show remote content" on every message.
    Thanks for any assistance.
    Norman

    I missed your 2nd question.
    This article explains how to always show remote content and the risks of doing so. You can make that call. Adding your trusted senders to your address book will allow content from them and is the recommended action.
    http://kb.mozillazine.org/Privacy_basics_(Thunderbird)

Maybe you are looking for

  • I have a 1st gen i pod touch and i cant get any apps can anyone help?

    i have the latest i pod software but i cant download any apps? when i go to the app store it tells me i need the ios 4 software or something but i think my i pod is to old. am i out of luck or can i still get games?

  • DMS - locked status / how to limit security access

    I have a couple issues with a security profile (customer service) we have defined for DMS.   This profile is set up that when the document info record is in a "released" status, the customer service person has edit (CV02N) access.  When in an "on hol

  • How do I save a numbers document as excel so it can be opened by windows?

    So i use my Mac Book Pro for some work documents, I use numbers and pages but since I updated to LION I cannot save any document as an excel it use to give me the option and now with auto save and versions it wont let me ive looked everywhere somebod

  • BDB XML 2.2.13 on Linux (CentOs)

    I installed BDB XML 2.2.13 on Linux machine. I have a few questions: 1. How do I set DB_HOME so that I don't need to give directory each time I run dbxml? 2. How do I create a container inside of another container: by saying this, the path I am looki

  • Shadow Instance Left Behind in SLD After Using SUM

    Hello, Is there a standard procedure for removing the SLD information left behind by the creation of shadow ABAP instances when using SUM to update or upgrade systems? Should SUM have some final step for this built in, or should the update instructio