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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying To Insert Multiple Lines Of Records

Status
Not open for further replies.

FontanaS

Programmer
May 1, 2001
357
US
I have a table called states that i would like to import the state names and abbreviations into.

I have tried the following in enterprise manager -
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES
('Alabama','AL':'Alaska','AK')

Not working. Is there a way i can do this, or do i have to insert each record seperatly?

THANKS!
 
Are the values you are trying to insert stored anywhere? If so, then:
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE)
SELECT (column that has the statename), (column that has the abbrev state)
FROM (the table that has this date)

If not, then this is the only way to go:
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('ALABAMA','AL') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('ALASKA','AK') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('AMERICAN SAMOA','AS') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('ARIZONA ','AZ') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('ARKANSAS','AR') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('CALIFORNIA ','CA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('COLORADO ','CO') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('CONNECTICUT','CT') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('DELAWARE','DE') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('DISTRICT OF COLUMBIA','DC') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('FEDERATED STATES OF MICRONESIA','FM') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('FLORIDA','FL') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('GEORGIA','GA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('GUAM ','GU') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('HAWAII','HI') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('IDAHO','ID') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('ILLINOIS','IL') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('INDIANA','IN') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('IOWA','IA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('KANSAS','KS') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('KENTUCKY','KY') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('LOUISIANA','LA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MAINE','ME') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MARSHALL ISLANDS','MH') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MARYLAND','MD') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MASSACHUSETTS','MA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MICHIGAN','MI') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MINNESOTA','MN') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MISSISSIPPI','MS') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MISSOURI','MO') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('MONTANA','MT') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NEBRASKA','NE') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NEVADA','NV') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NEW HAMPSHIRE','NH') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NEW JERSEY','NJ') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NEW MEXICO','NM') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NEW YORK','NY') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NORTH CAROLINA','NC') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NORTH DAKOTA','ND') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('NORTHERN MARIANA ISLANDS','MP') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('OHIO','OH') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('OKLAHOMA','OK') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('OREGON','OR') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('PALAU','PW') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('PENNSYLVANIA','PA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('PUERTO RICO','PR') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('RHODE ISLAND','RI') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('SOUTH CAROLINA','SC') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('SOUTH DAKOTA','SD') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('TENNESSEE','TN') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('TEXAS','TX') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('UTAH','UT') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('VERMONT','VT') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('VIRGIN ISLANDS','VI') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('VIRGINIA ','VA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('WASHINGTON','WA') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('WEST VIRGINIA','WV') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('WISCONSIN','WI') GO
INSERT INTO TBL_STATES (STATENAME,ABBREVAITESTATE) VALUES ('WYOMING','WY') GO

Replace GO with the delimiter that you use. Bring this text in notepad and do a find replace (Ctrl-H).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top