Sunday, February 19, 2012

cannot insert data from one table to another

Hello:
All I want to do is simply copy a column of data from one table to another.
The first time I tried it, I got that blame "cannot insert duplicate primary
KEY constraint" business or whatever. So, I decided to create a duplicate
table (backup table). I did that sucessfully. The point is that I created
a
backup table of the table that I want to copy into so that I could get aroun
d
this error.
I got around that error. But, now, when I try to copy the column from a
table into this backup table, I get a message saying that it cannot insert
the value "NULL" into some other column in the table that I do not care abou
t
anyway.
Is there any way to get around these errors? I just want to copy data from
one column for goodness sakes!!!
Thanks!
childofthe1980sThere is no way for anyone to help unless you provide quite a bit more
information. The error messages are symptoms, but to understand them
required the entire picture.
So, show the table structures (including those pesky keys), and show
what the data looks like, and describe more precisely what you are
trying to accomplish. Before and after views of the data help a lot.
Roy
On Sun, 26 Feb 2006 10:18:26 -0800, "childothe1980s"
<childothe1980s@.discussions.microsoft.com> wrote:

>Hello:
>All I want to do is simply copy a column of data from one table to another.
>The first time I tried it, I got that blame "cannot insert duplicate primar
y
>KEY constraint" business or whatever. So, I decided to create a duplicate
>table (backup table). I did that sucessfully. The point is that I created
a
>backup table of the table that I want to copy into so that I could get arou
nd
>this error.
>I got around that error. But, now, when I try to copy the column from a
>table into this backup table, I get a message saying that it cannot insert
>the value "NULL" into some other column in the table that I do not care abo
ut
>anyway.
>Is there any way to get around these errors? I just want to copy data from
>one column for goodness sakes!!!
>Thanks!
>childofthe1980s|||"childothe1980s" <childothe1980s@.discussions.microsoft.com> wrote in message
news:3C895F9B-8A38-4991-AD42-9B43F5EDFCB8@.microsoft.com...
> Hello:
> All I want to do is simply copy a column of data from one table to
> another.
> The first time I tried it, I got that blame "cannot insert duplicate
> primary
> KEY constraint" business or whatever. So, I decided to create a duplicate
> table (backup table). I did that sucessfully. The point is that I
> created a
> backup table of the table that I want to copy into so that I could get
> around
> this error.
> I got around that error. But, now, when I try to copy the column from a
> table into this backup table, I get a message saying that it cannot insert
> the value "NULL" into some other column in the table that I do not care
> about
> anyway.
> Is there any way to get around these errors? I just want to copy data
> from
> one column for goodness sakes!!!
> Thanks!
> childofthe1980s
DDL and sample data please if you expect a full working solution. See:
http://www.aspfaq.com/etiquette.asp?id=5006
In your INSERT you have to supply a value for the non-nullable columns that
don't have defaults.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

No comments:

Post a Comment