Quality Testing

Quality is delighting customers

 


Hi Folk,

How to insert multiple record using sql server 2005

for example: In employee table i have to enter 1000 records
then how to insert.

pls advice

Regards,
Faroz

Views: 451

Reply to This

Replies to This Discussion

Hi Firoz,

 

I  work on mySql, You can use in this way,

1. Take number of columns in excel sheet

2. Put the 1000 records which you want to insert

3. Add one one column in each filled column (to add commas and single quotes)

                        C1      C2       C3      C4     C5     C6     C7

                         ('        a         '.'        b       ','      c       '),

 

4. Now write your query in query browser

      insert into 'table name' values...

5. Copy the data from excel sheet and paste next to query

6. and then execute query.

 

(* if some unnecessary spaces are getting added between two values u can paste data from excel sheet to

  PSpad and remove spaces by 'find replace' )

 

I am not sure whether the way i use is effective..

Please let me know any other easy way.

 

-S Sarita

while replacing by find replace option it becomes complicated sometimes.....
Yes, U need be careful...while find and replacing
u can make use of Union All..!

 

Hi Sarita,

hw r u? Hope everything is 5n.

I have tried, but not working

i guess i did in wrong way

table & colum which i created is

Table: Employee

Column: Emp_id,Emp_Name, Emp_Add

so explain how to give the value in the below command

Insert into Employee Values.....

 

Regards,

Faroz

 

Insert into Employee values
(value of Emp_id, value of Emp_Name, value of Emp_Add),
(value of Emp_id, value of Emp_Name, value of Emp_Add),
(value of Emp_id, value of Emp_Name, value of Emp_Add),
(value of Emp_id, value of Emp_Name, value of Emp_Add);

Hi Sarita,

I tried in SQl Server 2005 not working

what i tried is

insert into Employee Values

(10,'Rahul','asadfadfad')

(11,'Ravi','aadasadfad')

(12,'Ramesh','asdasdfa')

(13,'Radha','asdasdaaf')

(14,'Ravan,'asasdfasdd')

(15,'Raju,'aadfasdfsd')

 

Error msg which i got is "Incorrect syntax near ',' "

 

Regards,

Faroz

Insert into Employee values
(value of Emp_id, value of Emp_Name, value of Emp_Add) and enter data then press "Enter"

and then "/" now u can enter the second record .. like this u can enter "n" number of records...

LOAD DATA LOCAL INFILE ‘C:\\temp\\yourfile.csv’ INTO TABLE database.table FIELDS TERMINATED BY ‘;’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\r\n’ (field1, field2);

 1st create xls file add  data in that .

 Load data local infine 'path of .csv file' into table tablename field terminated by .... etc

Hi Bheemlanaik and Shital patel,

 

Thanks for replying my query

 

Regards,

Firoz

hi

u can also try ecxel sheet(formula bar) to create insert query

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service