Inserting into a column with an identity column

I have two tables Alpha and Beta. I want to copy all of the records from Alpha into Beta, except for the "Id" column values of Alpha, which should be ignored. They should be ignored because the Beta "Id" values are auto incremented. So in other words, I just want to copy the "Name" column of Alpha into Beta. Assuming that when the insert occurs, the Beta Id values will automatically be added because they are auto incremented values. Can someone help me write the insert statement. I can't get it to work, because I don't know how to make the insert statement ignore the Id column on insert.

USE [Gimbro]
GO
/****** Object:  Table [dbo].[Alpha]    Script Date: 3/18/2015 4:41:08 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Alpha](
      [Id] [int] NULL,
      [Name] [varchar](50) NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Beta]    Script Date: 3/18/2015 4:41:08 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Beta](
      [Id] [int] IDENTITY(1,1) NOT NULL,
      [Name] [nvarchar](50) NULL
) ON [PRIMARY]

---------------Now add data to Alpha table----
GO
INSERT [dbo].[Alpha] ([Id], [Name]) VALUES (0, N'Malicter')
GO
INSERT [dbo].[Alpha] ([Id], [Name]) VALUES (0, N'James')
GO
INSERT [dbo].[Alpha] ([Id], [Name]) VALUES (0, N'Jelly')
GO
INSERT [dbo].[Alpha] ([Id], [Name]) VALUES (0, N'Germosoli')
GO
LVL 2
brgdotnetcontractorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
why would you want to have two tables having the same information excluding Id column)?

You can do insert into beta (select column1, column2, column3, ... From alpha)

Insert into beta (columns,.....) values (
..

You have to explicitly state which columns and corresponding data is included.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
My friend, I posted this because I was actually working with a bigger table and just made some small examples. I could not get it to work, and now I feel silly, because it works now. Blush, Blush. Thank you for you're help.

INSERT INTO Beta select Name from Alpha
0
brgdotnetcontractorAuthor Commented:
I made a mistake, and did not realize an error I had made, but now my code is working. Thanks.
0
arnoldCommented:
Glad I could help,  while I do not know the purpose, I would recommend preserving the Id reference from alpha table in beta table.
Presumably based on your last comment, you Alpha table was designed in a way that you now see a reason to restructure it.
Preserving the ID will/could maintain other table references to simplify transitions.

I.e. You have alpha, gamma, that have a relationship to alpha's ID. If my guesstimate in the reason is correct, you would also need to transition gamma table as well to match the new beta tables ID column.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.