question

sqlrookie avatar image
sqlrookie asked

create table not adding column

Hi, I have generated a script for a table with data. When i execute the script which has create table statement and insert statement, i end up getting error like missing column at insert statement.I went through the table and came to know that there is one column with datatype nvarchar(26) is not added to the table. I even tried to execute only create table statement with all columns but still cannot fine the one column in the table. How to resolve this?
columnsgenerate-script
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TimothyAWiseman avatar image TimothyAWiseman commented ·
Can we see the script (or at least the relevant part)?
1 Like 1 ·
dvroman avatar image dvroman commented ·
This sounds a whole lot like you have an invalid character in the column name. There should be an error reported.
0 Likes 0 ·
sqlrookie avatar image
sqlrookie answered
Here is the script, i have some 58 columns and in between one of the column is getting missed which has nvarchar(26) datatype, This script i have generated using generate script wizard with data option true. ` SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[table]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[table]( [ID] [varchar](27) NULL, [GUID] [nvarchar](36) NULL, [LastName] [nvarchar](50) NULL, [FirstName] [nvarchar](50) NULL, [BadgeNumber] [nvarchar](14) NULL, [Description] [nvarchar](100) NULL, . . . . . . . . ) ON [PRIMARY] END GO SET ANSI_PADDING OFF GO `
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Blackhawk-17 avatar image Blackhawk-17 commented ·
Can you post the whole script and identify which column does NOT get created? That way we can try to replicate the issue on our test systems.
2 Likes 2 ·
Jeff O avatar image Jeff O commented ·
Shouldn't this part of the question?
0 Likes 0 ·
Grant Fritchey avatar image
Grant Fritchey answered
Can you modify the CREATE TABLE script manually to add the column in question? If you do this, does the column still come up missing? If so, you have identified a major bug in SQL Server. Is it possible that the INSERT statement just has the wrong column name? A typo seems like a more likely answer.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.