Questions tagged [sql-insert]

The SQL INSERT statement allows you to insert a single or multiple rows into a table.

SQL INSERT statement adds one or more rows to a single table in a relational database.

The basic INSERT values syntax is:

INSERT INTO table [ (column1 [, column2, column3 ... ]) ]
VALUES (value1 [, value2, value3 ... ]);

The INSERT SELECT syntax is:

INSERT INTO table [ (column1 [, column2, column3 ... ]) ]
SELECT c1 [, c2, c3 ... ] FROM table

Reference

For questions regarding SQL INSERT statement use this tag instead of .

5071 questions
1
vote
1 answer

Managing logical constraint to handle concurrency in mySQL database insertion

I'm going to create a booking system. In this system there are some person with limited capacity to meet people in defined period of time. E.g. person A can have meeting with at most 8 person on Sunday between 8:00 to 12:00. In my database I have…
VSB
  • 9,825
  • 16
  • 72
  • 145
1
vote
1 answer

Mysql deadlock single insert transactions

In the following case I am seeing a deadlock detected, retry transaction error: Multiple insertions are occurring concurrently. Each insertion is done within a transaction for only a single row. (Each transaction only does one insert between its…
lf215
  • 1,185
  • 7
  • 41
  • 83
1
vote
1 answer

rSQL While Loop insert

*Updated - Please see below(Past the picture) I am really stuck with this particular problem, I have two tables, Projects and Project Allocations, they are joined by the Project ID. My goal is to populate a modified projects table's columns using…
1
vote
1 answer

inserting records into a table if values from src have changed

I have a STG table where we truncate and load values into the STG table from 2 SRC tables daily. I created a Change flag (Ch_Flg) and in the STG table so that instead of truncating the tables daily, we will insert values into STG only when certain…
1
vote
1 answer

OleDbException (x80040E14): Syntax error in Insert into statement

Can anyone help with this issue please? I've tried so many different things and I'm still getting this error. The error points to the line cmd.ExecuteNonQuery(). I've checked the Insert string a million times now and I don't see what's wrong with.…
testing123
  • 11
  • 1
1
vote
2 answers

How to insert square root symbol or unicode characters into SQL Server database

I am trying to insert square root symbol √ into my SQL Server database from an ASP.NET page. The radical symbol (√) gets inserted as letter v instead. Where could I be going wrong? Thanks for your assistance.
Raphael Mutiso
  • 63
  • 1
  • 11
1
vote
1 answer

How to execute INSERT INTO in SQLite with ODBC in c#

The function of application is to select some values from one database (PSQL) and insert it into another database (SQLite). But code below does not work, it stops at executing line and shows no error, but last forever (also if I use SELECT TOP 1…
DaniKR
  • 2,418
  • 10
  • 39
  • 48
1
vote
3 answers

CSV File to SQL Insert Statement

I have a CSV file that looks something like this: Date,Person,Time Out,Time Back,Restaurant,Calories,Delicious? 6/20/2016,August,11:58,12:45,Black Bear,850,Y 6/20/2016,Marcellus,12:00,12:30,Brought…
ThoseKind
  • 754
  • 2
  • 13
  • 22
1
vote
1 answer

In what order mysql triggers are invoked during INSERT ON DUPLICATE statement?

Here is 4 triggers which can be added to mysql table: before insert before update after insert after update Suppose that all triggers were added to the table. Then the insert on duplicate executed. What trigger are executed and in what…
Cherry
  • 31,309
  • 66
  • 224
  • 364
1
vote
2 answers

Unable to execute the function in plpgsql/postgres

I want to calculate distance from address points to all streets within a distance of 50 meters using plpgsql. I have tried the following function: Create or Replace Function get_dist(ad geometry, st geometry) Returns double precision…
1
vote
3 answers

What is the T-SQL syntax to fill the columns of a table in my database with the same set of data with continuous dates?

I am using SQL Server 2016 and I need to create a table (RoomInventory) in my database that will contain the following set of data which will be repeated for the period 01 January 2016 to 31 December 2016. Here is how I want the final table to…
user3115933
  • 4,303
  • 15
  • 54
  • 94
1
vote
2 answers

PHP postgresql: INSERT values from query array result

I have some rows from this query statement: SELECT * from jkd where idno='$id'; And I want to "copy" the values from those rows to other table: INSERT INTO tmpjkd(pop, name, address) VALUES($pop, $name, $address); I tried with this: $jkd = SELECT…
bandungeuy
  • 378
  • 4
  • 19
1
vote
1 answer

Only INSERT to all 4 tables successfully or not at all

At the moment I am trying to insert into 4 separate tables using 4 separate INSERT commands. I only want this to happen if all 4 of the INSERTS are successful. If any of the INSERT's fail then I do not want any of the data to be entered into the DB.…
David Jack
  • 87
  • 6
1
vote
4 answers

Insert a new row in Table2 for each column of Table1

Given the following table layout and data rows: SELECT [Id] ,[EmailAddress] ,[PhoneNumber1] ,[PhoneNumber2] ,[FaxNumber] FROM [Database].[dbo].[Table1] 1 NULL 800-222-2222 800-333-3333 800-444-4444 2 …
HappyCoding
  • 641
  • 16
  • 36
1
vote
2 answers

Postgresql insert table data into another table

I've got a database with a table containing different calendars (table events). Now I created a new table (events_backup) and imported all entries from table events from an older backup. Now I want to insert in the event table all entries for a…
susei
  • 11
  • 2
1 2 3
99
100