How to insert multiple records with a single query?
Hi,
I've to save a huge number of installments with their other information such as due on blah blah. Now, I want to add the all of these information at once with a single insert query.
How can I do that?
Hi
What is your source data?
If the source is external to the SQL Server (like a log file, Excel, CSV, JSON, XML, external application...) you can and should insert it all using Bulk Insert operation.
Pls clarify what is your source data, and if you need more help using Bulk Insert.
https://www.simple-talk.com/sql/learn-sql-server/bulk-inserts-via-tsql-in-sql-server/
http://msdn.microsoft.com/en-us/library/ms188365.aspx
[Personal Site] [Blog] [Facebook]
Similar Messages
-
How to insert multiple records in a single query
Dear all,
Can you please tell
how to insert multiple records in a single query ??INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
INSERT INTO table_name
(column_1, column_2)
SELECT 'value_A', 'value_B' FROM DUAL
UNION ALL
SELECT 'value_C', 'value_D' FROM DUAL
;Edited by: Benton on Nov 9, 2010 1:59 PM -
Mapping is inserting multiple records from a single source to Dimension.
Hi All,
I am very new to OWB. Please help me out. I've created Dimension with the help of the wizard and then a mapping which consist of single source and single dimension. The mapping is populating nearly 500 times of the actual records. Following are some details to give you a better understanding of mapping: I created a dimension with four levels and two hierarchy. Levels are L1, L2, L3 and L4 and hierarchies are H1-> L1, L2 and L4
and H2-> L3 and L4. L4 is lowest level of hierarchy. L1 and L3 are parent levels in the respective hierarchies. I assigned an attribute of each level as Business identifier that means business identifier attribute is different in each level. In mapping I mapped the parent natural key(Key for parent Level in a hierarchy) as the value which has been mapped for parent level. The result is coming 500 times of the record that exist in source table. I've tried even single common business identifier for each level but again the result is 5 times of the records. Please let me know the solution.
Thanks is advance.
AmitHi ,
You may not be having multiple records in your dimension.
To understand better the records insertion, try a snow flake version of the dimension and see how the records are inserted as per the levels in the respective tables.
Thanks -
How to insert multiple rows in a single insert statement in MaxDB?
hi,
I was looking at syntax but i could not get it right.. may be some could help me.
// Insert single row works fine
INSET INTO test_table(column_name) values (value1) IGNORE DUPLICATES
// Insert multiple rows, doesn't
INSET INTO test_table(column_name) values (value1), (value2), (value3) IGNORE DUPLICATES
Can somebody help me with this.
thanks,
sudhir.Multiple inserts do only work with parametrized statements, usually used in interfaces like JDBC, ODBC etc.
With static SQL statements it is not possible.
Regards Thomas -
How to insert multiple rows in a single shot using insert command?
Hi,
If we insert one row, we can use "insert into" command. I want to insert multiple rows into the table in a single shot. Is there any SQL command for insert multiple rows into the table?
Plese give the solution.
Thanks,
chelladuraiIf you would like to do it with SQL, this would be one of the ways to achive it:
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Sep 25 10:12:59 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Data Mining and Real Application Testing options
SQL>
SQL> desc leap
Name Null? Type
FIRST_PRICE NUMBER(16,6)
NEXT_PRICE NUMBER(16,6)
SQL>
SQL> select * from leap;
no rows selected
SQL>
SQL>
SQL> !vi multirow_insert.sql
SQL> !cat multirow_insert.sql
insert into leap(first_price, next_price) values (1,2);
insert into leap(first_price, next_price) values (3,4);
insert into leap(first_price, next_price) values (5,6);
SQL>
SQL> @multirow_insert.sql
1 row created.
1 row created.
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL>
SQL> select * from leap;
FIRST_PRICE NEXT_PRICE
1 2
3 4
5 6
SQL> -
How to insert multiple records?
I have dynamically checkboxes, which get the data from database. I have used a FOR loop to store each value of the checkbox to session variables, i.e.
session.setAttribute("Slangs"+a,request.getParameter("langsID"+a)); (p/s: a is a counter, I also set a hidden variable to store the number of record in DB)
Now, I wanna insert these records to the table called CusLangs which has CusID(PK) and Langs(PK). I wanna construct a insert.jsp, so that those checkboxes that I selected can be written into table CusLangs.
Anyone know how to do that?
Thanks.
From
jeffYou have a checkboxes with the same name in your html/jsp.When you post to a servlet/jsp, use request.getParameterValues("checkboxname ) to get String [], ie.
<html>
<input type="checkbox" name="sampleCheck" value="1">
<input type="checkbox" name="sampleCheck" value="2">
</html>
Servlet/ JSP
String check[] = request.getParameterValues("sampleCheck");
query = "Insert into CusLangs (CusID) values (?') ";
stmt = connection.prepareStatement(query);
for(int i=0, i < check.length, i++) {
stmt.setString(1, check[0]);
int x = stmt.executeUpdate();
Hope this will help. -
Inserting multiple records with DW CS3
I have a page with several input fields:
input: city1 input: state1
input: city2 input: state2
input: city3 input: state3
input: city4 input: state4
input: city5 input: state5
My current sql statement does retrieve the data correctly but
I can't figure out how to insert 5 new records at once.
INSERT INTO CS ( CID, Ccity1, Cstate1 ) SELECT
Contractors.CID, CS.Ccity1, CS.Cstate1
FROM Contractors INNER JOIN CS ON Contractors.CID = CS.CID
WHERE (((Contractors.CEmail)='[email protected]'));
The above values need to go into the table like:
CID | City | State
ID1 | city1 | state1
ID1 | city2 | state2
ID1 | city3 | state3
ID1 | city4 | state4
ID1 | city5 | state5
I need some help with my insert statement and how to insert
all my form inputs as I've shown above.>I have a page with several input fields:
>
> input: city1 input: state1
> input: city2 input: state2
> input: city3 input: state3
> input: city4 input: state4
> input: city5 input: state5
>
> My current sql statement does retrieve the data
correctly but I can't
> figure
> out how to insert 5 new records at once.
> INSERT INTO CS ( CID, Ccity1, Cstate1 ) SELECT
Contractors.CID, CS.Ccity1,
> CS.Cstate1
> FROM Contractors INNER JOIN CS ON Contractors.CID =
CS.CID WHERE
> (((Contractors.CEmail)='[email protected]'));
>
> The above values need to go into the table like:
> CID | City | State
> ID1 | city1 | state1
> ID1 | city2 | state2
> ID1 | city3 | state3
> ID1 | city4 | state4
> ID1 | city5 | state5
>
> I need some help with my insert statement and how to
insert all my form
> inputs
> as I've shown above.
You'll need to utilize the Commands implementation... hope
you're not using
ASP Classic 'cause it's broken in CS3. -
Insert multiple records with php
please help me
I have a problem in a multiple input records
please help ...............
example script:
<?php require_once('Connections/koneksi.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO mhs (NIM, NAMAMHS, ALAMAT) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['NIM'], "text"),
GetSQLValueString($_POST['NAMAMHS'], "text"),
GetSQLValueString($_POST['ALAMAT'], "text"));
mysql_select_db($database_koneksi, $koneksi);
$Result1 = mysql_query($insertSQL, $koneksi) or die(mysql_error());
$insertGoTo = "baru.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo));
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_koneksi, $koneksi);
$query_Recordset1 = "SELECT * FROM mhs";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $koneksi) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p> </p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table border="1">
<tr>
<td>NIM</td>
<td>NAMAMHS</td>
<td>ALAMAT</td>
<td> </td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['NIM']; ?></td>
<td><?php echo $row_Recordset1['NAMAMHS']; ?></td>
<td><?php echo $row_Recordset1['ALAMAT']; ?></td>
<td><table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">NIM:</td>
<td><input type="text" name="NIM" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">NAMAMHS:</td>
<td><input type="text" name="NAMAMHS" value="<?php echo $row_Recordset1['NAMAMHS']; ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">ALAMAT:</td>
<td><input type="text" name="ALAMAT" value="<?php echo $row_Recordset1['ALAMAT']; ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td> </td>
</tr>
</table></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<input type="hidden" name="MM_insert" value="form1" />
<input type="submit" value="Insert record" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>PowerMilk wrote:
I want to update multiple rows with one click on the submit button.Unfortunately, it doesn't work. What is wrong in the code?
It would be more helpful if you were to say what happens. "It doesn't work" isn't very helpful.
However, a quick look at your code reveals that your hidden field that contains the ID is outside the loop (repeat region) in your form. Move it inside the loop like this:
<?php do { ?>
<tr>
<td><input name="dag[]" type="text" value="<?php
echo $row_rsWijzigOpeningsuren['dag']; ?>" size="15" maxlength="15"
/></td>
<td><input name="voormiddag[]" type="text" value="<?php echo
$row_rsWijzigOpeningsuren['voormiddag']; ?>" size="15" maxlength="15"
/></td>
<td><input name="namiddag[]" type="text" value="<?php echo
$row_rsWijzigOpeningsuren['namiddag']; ?>" size="15" maxlength="15"
/></td>
</tr>
<input name="id[]" type="hidden" value="<?php echo $row_rsWijzigOpeningsuren['id']; ?>" />
<?php } while ($row_rsWijzigOpeningsuren = mysql_fetch_assoc($rsWijzigOpeningsuren)); ?> -
How to insert multiple records in DB table
HI Experts,
Jdev 11.1.2.3
I have requirement where my form belongs to two different tables (TableA and TableB).
In this form am using ADF shuttle component. The number of values i select in shuttle component same number of records to be inserted in TableB with each value.
on commit TableA and TableB both should be commited.
Thanks,
NiteshHi,
You can use a managed bean as the target of the value property of the shuttle component. Then in a value change listener you read the selected values and manually update the model. For this you could e.g. expose two view objects (one for each table) as an iterator to the PageDef file, access it from Java and then call dcIteratorBindingInstance.getRowSet().createRow() to create and populate new rows
The above is a bit rough in the outline, but so is the question
Frank -
How to insert multiple records into a table?
hi all
i have a table that name is : TiketsItem
now i want to 100 records insert my table
for example : TicketsHeaderRef=52000
Active=False
TicketsItemId=45000 to 45100
how to insert TicketsItemId 45000 to 45100 in my table
thanks all
Name of Allah, Most Gracious, Most Merciful and He created the humanSo, you just want to insert the serialized data into the table, without useDate or WKRef? I'm assuming these values will be updated later?
Try something like this:
DECLARE @TicketsHeader TABLE (TicketsItemID BIGINT, ticketsHeaderRef BIGINT, active BIT, useDate DATETIME, WKRef SMALLINT)
DECLARE @startInt BIGINT = 45000
WHILE @startInt <= 45100
BEGIN
INSERT INTO @TicketsHeader (TicketsItemID, ticketsHeaderRef, active)
VALUES (52000, @startInt, 0)
SET @startInt = @startInt + 1
END
SELECT *
FROM @TicketsHeader
thanks
i edited your codes:
DECLARE @TicketsItem TABLE (TicketsItemID BIGINT, ticketsHeaderRef BIGINT, active BIT, useDate DATETIME, WKRef SMALLINT)
DECLARE @startInt BIGINT = 45000
WHILE @startInt <= 45100
BEGIN
INSERT INTO @TicketsItem (TicketsItemID, ticketsHeaderRef, active)
VALUES (@startInt,52000 , 0)
SET @startInt = @startInt + 1
END
when i execute:
SELECT * FROM TiketsItem
i do not see any records inserted in TiketsItem
how to solve it?
Name of Allah, Most Gracious, Most Merciful and He created the human -
How to return multiple record with Oracle Native Web Service?
Dear all,
I would like to know that the oracle native web service can be able to return multiple records to client or not?
I successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)
Thank and Regards,
ZenoniI successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)You could return a list (multiple values/records) in XML format (using XMLType or CLOB), or CSV, or JSON, or whatever.
function get_employees (p_department_id in number) return clob
as
begin
return 'your_xml_string_here';
end get_employees;It would be up to the client (the caller of the web service) to extract the values from whatever format you decide upon, of course.
- Morten
http://ora-00001.blogspot.com -
How to calculate multiple aggregation in a single query
how to find firstname ,lastname for max and min salary from employees table group by department in a single query?
Edited by: Gnanasekar on Jan 10, 2012 6:36 AMcheck this query
select ENAME,SAL
from EMP
where SAL in(select max(SAL)
from EMP
group by DEPTNO)
or SAL in(select min(SAL)
from EMP
group by DEPTNO)Hope this will help you..
You should ask this question at sql/plsql forum
If someone's response is helpful or correct, please mark it accordingly. -
How to use multiple aggregate functions in single query
hi to all
The output will be giving first_name,last_name,max(salary),min(salary) and the output will be department wise.From employees table in single query
output will be:
first_name|last_name|max(salary)|min(salary)SELECT first_name||' '||last_name as ename,
MIN(sal) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) "Lowest",
MAX(sal) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) "Highest"
FROM emp
ORDER BY deptno, sal;Edited by: Ramio on Jan 10, 2012 10:43 PM -
How to insert multiple queries into a single worksheet of same dataprovider
Hello friends,
My question is same as this.I want to know how to create a single worksheet(workbook) embedded with multiple queries of same DATA PROVIDER with different VARIABLES assigned to each query.
Please,send me the relevant steps.
Regards,
Mohan Chand Reddy AHi,
You need to create one query workbook and rest of the queries you can insert manually from Bex tool -
insert query.
You need to insert query by adding one more tab in the workbook.
Keep in mind only one thing that variable ..if you are going to keep variable it will keep on popping up for user entry in it.
So try to have common variable in the first query and then those value needs to get fed into other query variable as they are running so without any user entry while execution we can see results in all the queries in the workbook.
If you want to insert a query into a new workbook:
Choose the symbol for Open...from the BEx toolbar. This brings you to the screen Open SAP BEx:
Select Queries from the left column.
Select a query from all those available. The queries are arranged according to InfoProviders.
Double-click on the required query or choose OK.
If you want to insert a query into the active workbook:
Open a workbook and, from the BEx toolbar, choose Tools ® Insert Query.... The query is then inserted into the current worksheet starting at the active cell.
If you want to insert a query into a workbook template:
Create a workbook template.
Insert the query into the workbook template.
Thanks and regards
Kiran -
How to insert multiple values from a single LOV box...?(cont)
Hi..I have a medical form and under the conclusions box, I have set up a LOV with various values. That part works fine.
The thing is I do not want to pick a single value. The format which I write in the conclusions in that box is
1. "............"
2. " "
3...etc...
But when I go to choose the 2nd value, it replaces the first one I had inserted. Any tips please??"My way", should have done exactly that. Every time you open the lov and choose a value it should be aapended to the already existing value in the textfield (assuming taht the length of the textfield is long enough)."
-Well thats the thing, If I try to add more than one value into ONE text field when I open up the LOV..it just replaces the first value with teh second value. Right now wihtout the LOV this is the format it gets stored into the database. The conclusions are typed in manually and when i query from sql plus it comes the way I typed it in. For example:
1. Mild concentric LVH
2. Normal LV systolic function ; EF 75 %
3. Diastolic dysfunction
I just copy/pasted that from sql. This is saved in a column in a table named ProcedureSummary. I want to insert values exactly this way into one field. Except when i do that currently with the LOV, it replaces the old value with a new value.
I hope i make sense, sorry for the bother!
Maybe you are looking for
-
I can't find where to update my iOS 5. I have looked under Settings then General, after that there is no where that shows update for this app. I have used it since I received my ipod. Was using AIM and now that doesn't work anymore. Try to downlo
-
ITouch iOS 6.1.3 not supported with bose iPod dock
We just had a Bose lifestyle v35 system installed in our home. The system sounds great and works seamlessly with all products except my iTouch V 5, iOS 6.1.3. The problem is not a faulty dock because earlier versions of iPod work quickly as described
-
Goods Issue in SD delivery (from vendor consignment stock)
Hi, all. I'm trying to make a goods issue in SD delivery from a vendor consignment stock (movement 601K), but the system gives me an error message M7071 - I have to enter a vendor at item level, but where? And if I have a stock determination strategi
-
Did the swooshy effects go away with 7.0.3?
Maybe I turned something off, but I don't think so ... Now screens just "appear" where before they sort of swooshed in from the corner. Subtle changes happen, no one says anything, and I think I'm going nuts ...
-
Delivery date showing wrong in VA02
Hi, I have a FG and 2child items. For FG, Inhouse Manufactured time and GR Processing I have maintained is "0" and for both the child items planned delivery time is "0". I have raised a Sale Order for the FG with Delivery date as Today i.e 06-07-2011