SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 inserting multiple values at once in a table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jonekim
Starting Member

Nepal
35 Posts

Posted - 04/06/2012 :  11:22:40  Show Profile  Reply with Quote
I've 3 tables:
1. userTABLE
- USERNAME (jone)
2. productTABLE
- prd_name (prd1, prd2, prd3)
3. paidTABLE
- USERNAME
- prd_name
- paid_amt

My query is to insert amount paid by jone for the 3 products.
One way is: I've to seperately insert paid amts by jone for every product he buys.

create proc paid @USERNAME varchar, @prd_name int, @paid_amt int
as
insert into paidTABLE values (@USERNAME, @prd_name, @paid_amt  )

Is there any way to insert the value of paid_amt at once in the table by jone for the 3 products?

jonekim
Starting Member

Nepal
35 Posts

Posted - 04/06/2012 :  11:27:40  Show Profile  Reply with Quote
My another query is:
how to delete the value of particular entity. suppose I want to delete only the value of prd_name but not USERNAME & paid_amt from the paidTABLE for a given row?
Go to Top of Page

Xiez
Starting Member

13 Posts

Posted - 04/06/2012 :  18:30:18  Show Profile  Reply with Quote
I'm having troubles understanding what you're asking, but I THINK what you're wanting to do is use the UPDATE function.

A google search will help with the syntax, but it's something like:
UPDATE paidTABLE
SET prd_name = null
Where USERNAME = 'Bob'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47069 Posts

Posted - 04/06/2012 :  21:00:13  Show Profile  Reply with Quote
quote:
Originally posted by jonekim

I've 3 tables:
1. userTABLE
- USERNAME (jone)
2. productTABLE
- prd_name (prd1, prd2, prd3)
3. paidTABLE
- USERNAME
- prd_name
- paid_amt

My query is to insert amount paid by jone for the 3 products.
One way is: I've to seperately insert paid amts by jone for every product he buys.

create proc paid @USERNAME varchar, @prd_name int, @paid_amt int
as
insert into paidTABLE values (@USERNAME, @prd_name, @paid_amt  )

Is there any way to insert the value of paid_amt at once in the table by jone for the 3 products?


how do you get amounts for the products? is it input by users?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jonekim
Starting Member

Nepal
35 Posts

Posted - 04/07/2012 :  02:21:38  Show Profile  Reply with Quote
@ visakh16.
the amounts for the products are the input by the users.
i.e they should be input in exec statement
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47069 Posts

Posted - 04/08/2012 :  18:15:33  Show Profile  Reply with Quote
how do you input multiple values?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000