Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 how to specify destination rows when import data?

Author  Topic 

yyc
Starting Member

5 Posts

Posted - 2005-05-05 : 18:41:29
Hi, I am new to Sql Server 2000. I am having some problem in importing data to sql table.

For example, in database table, I have two columns, column A and column B. column A already have 50 rows of existing data whereas column B is empty.

When I use the DTS wizard to import a .txt or .xls data to column B, the data will be inserted started at column B, row 51 and onwards. This is not the result I want. What I want is the data to be inserted at a specified row of column B, let say, column B, row 15 and onwards. Can this be done in Sql Server?

Really hope that some one would help me this, thanks.

yyc

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2005-05-08 : 05:36:04
1. NO. You can not do that.
2. Import the data into a temp table. Subsequenlty write a query to
update column B:

3. Also If you are planning import the data into any rows of column B that means there no relation between column A and Column B. You can as well move column A, B to seperate tables...




------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

yyc
Starting Member

5 Posts

Posted - 2005-05-10 : 20:52:52
Thanks a lot, ravilobo. Finally there is some one is replying me.

Anyhow, the column A and B in the table is related. My column A is "Teacher_Name", and column B is "School_id". It means that for each teacher, he/she will be assigned to one school where the school is indicated using "School_id". If let say I have 100 teacher's name, and at the time only 50 teachers are assigned to the particular "School_id" (Because not all the scholl_id will be assigned to all teachers due to some situation), so I need to update the subsequent teachers with their respective "Schoool_id".

Sorry again if my question is ambiguous and I will try to use temp table and see what can I do with it. Thanks.

yyc
Go to Top of Page

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2005-05-11 : 02:51:25
Some hints
1. Create a temp table with teacher and their ID's
2. You already have a main table where all the teachers are present.
3. There should be one common column in both these tables
4. In your case it is teachers.
5. Update the main table form the temp table using update query...

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

yyc
Starting Member

5 Posts

Posted - 2005-05-12 : 10:20:50
Oh yes, your hint is useful to me (better than what I am doing), thanks!

yyc
Go to Top of Page

hadi
Starting Member

1 Post

Posted - 2005-05-27 : 10:55:16
Hi.

I am trying to import data from Excel into an existing table. The catch is that I want to update specific rows. How do I create a temp table, populate it with the data to import and them match that up with the existing table based on the PK, which is ID in this case?

Basically, I am trying to do what yyc is asking about, but I need some assistance with SQL syntax related to the hints


Thanks
Go to Top of Page
   

- Advertisement -