Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting new data

Status
Not open for further replies.

nuttyernurse

Technical User
May 18, 2009
35
US
Hello all!

I'm new to sql and have a need to insert new data into a table. I could manually type it, but there are several hundred entries that need to be made. This is a printer assign table for all devices connected to the system. Each device needs to be added three times with the print types of text, postscript, and barcode. The fields are:
Db_Name, Tty_ID, Tty_Host, Print_ID, Print_Host, Print_Type, and Printer_Name. I have attached a screen shot of the actual table.

Any direction is greatly appreciated.

Thank you,
Michael
 
You have a number of options among which:
1- Use the Import Data wizard
2- Use the bulk copy utility (bcp)

I recommend the Import Data wizard. To use it connect to SSMS, right-click your database, choose Tasks then Import Data. Follow the steps to import the data, it' s really straightforward. Your file looks like a CSV one.

Assuming the original batch contains one of the three devices in the Print_Type column, to add the same data with a different type, one way could be to duplicate the original table in the same DB, update the Print_Type column in the temp table with the next Print_Type value, then INSERT the rows into the table and repeat the process for the third Print_Type value. To avoid conflicts if you have a primary key other that an autoincrement field setup, Print_Type will have to be part of the key.

The statement to insert into your permanent table from the temporary one should look like this:
Code:
INSERT PermaentTable
    SELECT Col1, ...Coln FROM TempTable

Good luck.

MCITP SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
 
TheBugSlayer You Are The Best!!!!!!

Thank you, worked like a charm!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top