13
Insert data into the SQL table
source link: https://www.codesd.com/item/insert-data-into-the-sql-table.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Insert data into the SQL table
advertisements
The Data in my DataTable is like
ID ContactName1 Designation1 ContactName2 Designation2
1 A dummy B sam
The Table structure of my Table is
ID ContactName Designation
I am passing the values in the stored procedure as:
@ContactName1
@Designation1
@ContactName2
@Designation2
I want a single insert statement to insert the records.
How can I achieve this?
Assuming your ID primary key is set on auto-increment, and your table has three fields:
INSERT INTO DataTable (ContactName, Designation) VALUES
(@ContactName1, @Designation1),
(@ContactName2, @Designation2);
As per the actual ID, if you don't have it on auto-increment, which judging from the comment on Ivan's response, you don't, you could actually get it using the MAX() statement:
SELECT MAX(ID) AS max_id FROM DataTable
Related Articles
how to avoid re-inserting data into the sql table when replaying the SSIS package that loads the data from the flat file to the SQL table?
I have a flat file with the following data Id,FirstName,LastName,Address,PhoneNumber 1,ben,afflick,xyz Address,5014123746 3,christina,smith,test address,111000110 1,ben,afflick,xyz Address,5014123746 3,christina,smith,test address,111000110 4,nash,go
Inserting data into the SQL table from the asp.net form
I am trying to build a registration web form which saves user data into an SQL table. This is what I have so far: public static SqlConnection GetConnection() { String connection; connection = @"example/file/path"; return new SqlConnection(connec
Insert data into the SQL table safely and avoid the sql insert error
MyI created a form that should gather information from data. This data may include random characters including " ' and so on. My question is how do I insert data safely without having sql injection attacks and where could i insert escape characters s
Inserting data into the SQL table from the HTML form
A HTML form has been created that should (when filled) send the data it's holding to a database inserting a new row so it can be used later on. However, I can't seem to get it to work, I'm getting the following error: Notice: Use of undefined constan
How to insert data into the sql server database
I'm trying to insert data into my SQL Server 2014 database, but I get an error Incorrect syntax near ')'. My table matches the types of data I put in, for example, I'm put an int into a int. Here is my code: string ip = Request.UserHostAddress; strin
& ldquo; select * in the & rdquo; Will it work for inserting data into the existing table
I am trying to insert data from one of my existing table into another existing table. Is it possible to insert data into any existing table using select * into query. I think it can be done using union but in that case i need to record all data of my
Inserting data into the Hive table
I am new to hive. I have successfully setup a single node hadoop cluster for development purpose and on top of it, I have installed hive and pig. I created a dummy table in hive: create table foo (id int, name string); Now, I want to insert data into
Insert data into an SQL table from an Excel sheet
if I have the following table in SQL, Item Desc Type Location Quantity Unit_Price A AAA X 1 0 20.00 B BBB Y 2 0 10.00 B CCC X 2 0 50.00 C DDD Z 1 0 150.00 C EEE Y 3 0 70.00 D FFF Z 3 0 65.00 And the following Excel Sheet Item Location Quantity A 1 1
How to insert data into an SQL table using C # and implement a download function?
Below is the code I am working with to try to insert data into my 'ArticlesTBL' table. I also want to upload an image file to mt computer. Previously I was working in Visual Studio just with the data controls within my .aspx file to insert data, so t
Insert data into the html table provided in the web application using the selenium web driver
I am working on selenium webdriver and i want to insert data into the tables which are provided on web site, i have used sendkeys method but its not working for me. is there any other way to insert data into tables ?Inserting data using selenium the
Download the csv file, parse, and then insert the data into the SQL table
Have a webform that has an upload button to upload csv file then my code needs to parse the file and use the parsed data to insert into a SQL table. Is what I'm doing correct for the parse data to a List, it's not picking up the filename for the stre
Spark SQL - insert data into the hive table from another hive table error
I want to insert data into hive table from another hive table using Spark SQL. I am getting below error. My code: SparkConf conf = new SparkConf().setAppName("GetHiveTableData"); JavaSparkContext sc = new JavaSparkContext(conf); JavaHiveContext
C # Fastest way to insert data into the SQL database
I am receiving (streamed) data from an external source (over Lightstreamer) into my C# application. My C# application receives data from the listener. The data from the listener are stored in a queue (ConcurrentQueue). The queue is getting cleaned ev
How to insert data into the mysql table randomly
I have created a script that get data from other website and insert or add it in mysql table. When I use to get data from website, It runs correctly but when I insert it in mysql I cannot do that thing. it shows me error, i.e. Error: INSERT INTO body
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK