I get these errors:
Invalid column name 'Addmin'.
Invalid column name 'Addmin'.
The multi-part identifier "Admin@hotmail.com" could not be bound.
Invalid column name 'P@55word'.
Invalid column name 'BioMedical_Sciences'.
I am trying to enter data into a table. I have included my create table code too so you can look at the data types and so on.
CREATE TABLE Accounts
(
ID INT NOT NULL,
FIRSTNAME CHAR(20) NOT NULL,
SURNAME CHAR(20) NOT NULL,
EMAIL CHAR(50) NOT NULL,
PASSWORD CHAR(20) NOT NULL,
AGE INT NOT NULL,
COURSE CHAR(25),
PRIMARY KEY (ID)
);
ALTER TABLE Accounts
ALTER COLUMN FIRSTNAME CHAR;
ALTER TABLE Accounts
ALTER COLUMN SURNAME CHAR;
ALTER TABLE Accounts
ALTER COLUMN EMAIL CHAR;
ALTER TABLE Accounts
ALTER COLUMN PASSWORD CHAR;
ALTER TABLE Accounts
ALTER COLUMN AGE INT;
ALTER TABLE Accounts
ALTER COLUMN COURSE CHAR;
INSERT INTO Accounts (ID, FIRSTNAME, SURNAME, EMAIL, PASSWORD, AGE, COURSE)
VALUES (1, Addmin, Addmin, Admin@hotmail.com, P@55word, 19, BioMedical_Sciences);
Default char length is 1.
https://docs.microsoft.com/en-us/sql/t-sql/data-types/char-and-varchar-transact-sql
When you altered the column types, you reset the char column sizes to 1, and hence the truncation is occurring.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.