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)
 Data import from Excel 2003 file

Author  Topic 

jasonlum
Starting Member

2 Posts

Posted - 2011-01-20 : 18:04:12
Hi

I would like to know how to import data from an Excel file into a table that has a primary key of type uniqueidentifier and is auto generated using the newid(). Following is the create table:

CREATE TABLE [dbo].[Schools](
[SchoolId] [uniqueidentifier] NOT NULL CONSTRAINT DEFAULT (newid()),
[SchoolName] [nvarchar](556) NOT NULL,
[RegistrationNumber] [nvarchar](50) NULL
)

In my excel file, I have two columns: SchoolName and RegistrationNumber. There are about 5000 records to read.

I tried using SSIS but could not figure out a way to reference the SchoolId field. Is there any working example that I can use as a reference with SSIS to do the job.


Thanks
Jackson



tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-01-20 : 18:06:56
Why do you want to use a GUID? Use an identity column instead. GUIDs are evil!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jasonlum
Starting Member

2 Posts

Posted - 2011-01-20 : 18:21:12
quote:
Originally posted by tkizer

Why do you want to use a GUID? Use an identity column instead. GUIDs are evil!

Tara Kizer



My database will be used with other systems that connect to other databases so to avoid duplicated ids.
Go to Top of Page
   

- Advertisement -