I need to upload several thousand addresses to a web portal. I do not have access to the site itself and must do so with the following INSERT statement:
INSERT INTO Address (AddressTypeID, Address1,City, State, Zip, Phone, PersonName, DisplayName, IsDefault, StatusID, UserID)
VALUES ('1', 'SQL Herro st', 'SLC', '42', '84087', '8015957258', 'Bruce Wayne', 'Bruces address', 'False', '1', '3019')
I have the addresses in Excel but I don't really have any idea how to iterate this code a thousand times while importing the data.
One time: could right click database instance and choose Task-> Import Data. Automatic: build SSIS package and schedule job in SQL server to run ETL process.
You have different options depending on which server you are using, but with your current info you could do the following.
Paste the following code
="INSERT INTO Address (AddressTypeID, Address1,City, State, Zip, Phone, PersonName, DisplayName, IsDefault, StatusID, UserID) VALUES '"&A2&"', '"&B2&"', '"&C2&"', '"&D2&"', '"&E2&"', '"&F2&"', '"&G2&"', '"&H2&"', '"&I2&"', '"&J2&"', '"&K2&"'"
Check to see if the query is correct, it's calculated with the fields from a2-k2)
copy -> paste special values only to the next column, so you keep your code, but you can select all rows with the calculated results to your sql query tool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With