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 2005 Forums
 SSIS and Import/Export (2005)
 need help in importing forum data

Author  Topic 

7 Gates Of Hell
Starting Member

3 Posts

Posted - 2007-01-13 : 21:48:36
hi,

i am building a forum in asp (just for fun).
i have a mssql 2005 server, and i want to merge\import data from another mssql 2000 server.
but i dont know how to do it correctly.

i have some tables like this
[forum_c]
forum_c_id (PK, int, not null)
forum_c_name (varchar, not null)

[forum_sc]
forum_sc_id (PK, int, not null)
forum_sc_cid (int, not null)
forum_sc_name (varchar, not null)

etc...

forum_c meaning "forum categories", and forum_sc "forum sub categories".
forum_sc_cid has the value of forum_c_id to know to what categorie it belongs to.

but i dont know how to import it and keep the correct id's.
can somebody please tell me what i need to do???

if you need anymore info to help me just ask.

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-15 : 13:07:51
I assume you are trying to run INSERT ... SELECT statements and getting errors saying you can't specify values for an identity column? If so, you need to use the SET IDENTITY_INSERT statement to allow inserting specific identity column values when you perform the import, and then use it again to return the table to normal identity column handling.
Go to Top of Page

7 Gates Of Hell
Starting Member

3 Posts

Posted - 2007-01-16 : 17:38:48
no i am trying to use the import manager.

and the problem is i am trying to merge from another database,
so the entrys from the other server must get new identity numbers.

and also when someone doesn't login (a guest) and he\she posts a message,
i use a 0 in the "forum_p_gid" field and i get the name the guest entered from "forum_p_name".
and i then i dont know how to correctly set the relations. (because the mssql wont like it when it can't find the id number)

[forum_p]
forum_p_id (PK, int, not null)
forum_p_tid (int, not null)
forum_p_gid (int, not null) << user id
forum_p_name (varchar, null) << name that guest typt


p.s. sorry for bad english because it's not my main langue
Go to Top of Page

7 Gates Of Hell
Starting Member

3 Posts

Posted - 2007-01-21 : 18:56:01
*bump*
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-22 : 01:02:37
You could write a stored procedure on the target server like this
create procedure db.uspMergeForums
(
forum_c_name varchar(100),
forum_sc_name varchar(100)
)
as

declare @id int

insert forum_c (forum_c_name)
select @forum_c_name

select @id = scope_identity()

insert forum_sc (forum_sc_cid, forum_sc_name)
select @id, @forum_sc_name


and then you have to call the sp for every row in the source table.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -