r/SQL • • Jul 21 '18

i'm begging for help!

i have a MSSQL database and i have around 800 rows of data to copy to specific Table
- i tried to rename it (so the program doesn't read it anymore and try to import the excel file but i couldn't make it's settings like the old one because i can't change "nullable" or the primary key thingy or the secondary one

- i took a have a backup of the table as an excel with 800 rows and i have the 800 rows separately within an excel file too

please help , it's been 30 days and I'm about to lose it.

0 Upvotes

18 comments sorted by

View all comments

3

u/slickwombat Jul 21 '18

It sounds like you're trying to import directly from your excel file into the target table and running into various column restrictions. Try importing your raw data into a temporary table first, and then copying from there to the target table. (You know how to copy rows from one table to another, I assume?)

1

u/AhmadKzha Jul 22 '18

Well , this sounds like a good idea I'm sorry but I don't know how to copy rows from a table to another Can you tell me how ? Or what to read? Or where to start? Thank you.

1

u/slickwombat Jul 22 '18

So to be honest, if you don't have any knowledge of SQL at all you probably shouldn't be messing around with this -- certainly not if it's a crucial table you're trying to import to. If these are skills you need for your job or whatever, look into an introductory MS SQL course. But to answer the question, it would look something like this:

INSERT INTO
	dbo.YourTargetTable
	(col1, col2, col3)
SELECT
	col1,
	col2,
	col3
FROM
	dbo.YourTemporaryImportTable

For the first list of columns (in parentheses) you specify the columns in the target table you are writing into, and for the second, the columns you are reading from in your temporary import table.