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
 SQL Server Administration (2005)
 sql question

Author  Topic 

sqlserverdeveloper
Posting Yak Master

243 Posts

Posted - 2009-07-06 : 17:15:19
I have two tables, below are the two table scripts:

Create table dbo.Departments
(ID int IDENTITY(1,1) PRIMARY KEY,
Dept varchar(100))

Create table dbo.Employees
(ID int IDENTITY(1,1) PRIMARY KEY,
dept_ID INT REFERENCES Departments(ID),
Employee varchar(100),
[EmpID] [uniqueidentifier])

I have inserted the data from excel spreadsheet into dbo.Departments table.

I have the list of employees in excel which I have to insert into dbo.Employees table, I inserted that data into dbo.Employees table, after inserting the employees the two columns dept_ID and EmpID are showing as nulls when I open the table.

How can I insert the data into the two cols dept_ID and EmpID of dbo.Employees table??

Thanks!

vani_r14
Starting Member

24 Posts

Posted - 2009-07-06 : 18:08:52
Hi

I found this way to be easy and helpful

http://www.mssqltips.com/tip.asp?tip=1430

Or the other way is to import the data from Excel into Sql Server
using the Import Export Wizard -

Open the Entrise manager / Management Studio. Expand Databases and find your db. Right click, then choose "All Tasks". From there choose Import Data. Follow the on line prompts. MAke sure you choose your version of Excel as the source. And choose which db and table to import. Once you have choosen everything, let it run either immediately or whenever you want it to.

and that should solve the issue..

vani
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-07-07 : 19:24:56
Apropos of nothing...

Why do you have an IDENTITY column and a uniqueidentifier column in the same table?

And before you ask, "Yes, I am just that anal-retentive!"

=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)
Go to Top of Page
   

- Advertisement -