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
 Transact-SQL (2005)
 Turning Off Primary Key for Inserting Data

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2009-10-29 : 16:34:34
Hi,

I am trying to insert some data into the table which is the result of a select statement. The problem is that one of the fields it is trying to insert is the primary key. Is there anyway I can ignore it without havin g to specify all the names of the column?

Mohammad Azam
www.azamsharp.net

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-29 : 17:31:35
show us your query..
make primary key IDENTITY(1,1) field or
SET IDENTITY_INSERT your_table OFF or
Make the fields you do not want to specify default value for NULL (if that is what you want)

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

azamsharp
Posting Yak Master

201 Posts

Posted - 2009-10-29 : 18:03:18
Query is something like this:

insert into T1
select * from T2

T1 has the first column as uniqueidentifier field which is also the Primary Key.

Thanks,



Mohammad Azam
www.azamsharp.net
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-10-29 : 18:38:22
is it an identity field?

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -