[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

MSSQL APPLYING COLUMN PROPERTIES TO EXISITNG TABLE

I am trying to apply the column properties from one table to another. The second table has identically structured data but the columns have different properties and I keep getting a truncated error message when using "INSERT INTO" from one table to another.

Any suggestions would be appreciated.

I tried using the following and was returned a syntax error:

UPDATE PATRONLOADZETA
SET UserName=<UserName,varchar(20),>, LastName=<LastName,varchar(40),>, FirstName=<FirstName,varchar(40),>, SSN=<SSN,varchar(20),>, Status=<Status,varchar(15),>, EMailAddress=<EMailAddress,varchar(50),>, Phone=<Phone,varchar(15),>, Department=<Department,varchar(255),>, NVTGC=<NVTGC,varchar(20),>, NotificationMethod=<NotificationMethod,varchar(8),>, DeliveryMethod=<DeliveryMethod,varchar(25),>, LoanDeliveryMethod=<LoanDeliveryMethod,varchar(25),>, Cleared=<Cleared,varchar(3),>, Web=<Web,varchar(3),>, Address=<Address,varchar(40),>, City=<City,varchar(30),>, State=<State,varchar(2),>, Zip=<Zip,varchar(10),>, Site=<Site,varchar(40),>
0
notcjw
Asked:
notcjw
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
You need an alter table statement in order to change the existing datatype / column length

ALTER TABLE PATRONLOADZETA alter column UserName varchar(20)
0
 
notcjwAuthor Commented:
Thanks That did the trick.

I have another problem. I am getting a truncation error for:

BULK INSERT PATRONLOADZETA2 FROM 'c:\johnharris\PATRONLOADFORILLIAD4.txt' WITH (FIELDTERMINATOR=',',ROWTERMINATOR=' ' )

It is saying Column 13 has bulk conversion error

Column 13 HAS PROPERTIES: (varchar(3),NULL)
i am simply inserting the string:  YES
I the input file the field appears correct  ,YES,
(WITH NO QUOTATION MARKS)

I am perplexed.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Tackle projects and never again get stuck behind a technical roadblock.
Join Now