Quantcast
Viewing all articles
Browse latest Browse all 15889

(1 row(s) affected) Msg 8152, Level 16, State 14, Line 2 String or binary data would be truncated.

I am working on a project for college and I cannot figure out why I am getting these errors. Here is my code and errors I am receiving. in addition, I none of the data is being entered expect for two repeatedly

(1 row(s) affected)
Msg 8152, Level 16, State 14, Line 2
String or binary data would be truncated.
The statement has been terminated.
Msg 8152, Level 16, State 14, Line 3
String or binary data would be truncated.
The statement has been terminated.

(1 row(s) affected)
Msg 8152, Level 16, State 14, Line 3
String or binary data would be truncated.
The statement has been terminated.

/*Use master database*/
USE master;
GO



/*Use KudlerFineFoodVirtualOrg database*/
USE KudlerFineFoodsVirtualOrg
GO

/*Create Job_Title table*/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Job_Title]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Job_Title](
    [Job_TitleID] [int] IDENTITY(1,1) NOT NULL,
    [JobTitle] [varchar](50) NULL,
    [Job_Description] [text] NULL,
    [EEO_1_Classification] [varchar](50) NULL,
    [Exempt_Status] [varchar](20) NULL,
 CONSTRAINT [PK_Job_Title] PRIMARY KEY CLUSTERED
(
    [Job_TitleID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO

/*Create Employee table*/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Employee]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Employee](
    [EmployeeID] [int] IDENTITY(1,1) NOT NULL,
    [LastName] [varchar](50) NULL,
    [FirstName] [varchar](50) NULL,
    [Address] [varchar](200) NULL,
    [City] [varchar](50) NULL,
    [State] [varchar](20) NULL,
    [Telephone_Area_Code] [int] NULL,
    [Telephone_Number] [varchar](50) NULL,
    [Employer_Information_Report_EEO_1_Classification] [varchar](20) NULL,
    [Hire_Date] [datetime] NULL,
    [Salary] [decimal](9, 2) NULL,
    [Gender] [char](1) NULL,
    [Age] [int] NULL,
    [Job_TitleID] [int] NULL,
 CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
(
    [EmployeeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Employee_Job_Title]') AND parent_object_id = OBJECT_ID(N'[dbo].[Employee]'))
ALTER TABLE [dbo].[Employee]  WITH CHECK ADD  CONSTRAINT [FK_Employee_Job_Title] FOREIGN KEY([Job_TitleID])
REFERENCES [dbo].[Job_Title] ([Job_TitleID])
GO
ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [FK_Employee_Job_Title]

/*Insert data into Job_Title table*/
INSERT [dbo].[Job_Title]
           ([JobTitle]
           ,[Job_Description]
           ,[EEO_1_Classification]
           ,[Exempt_Status])
SELECT 'Assistant manager','Job Description',5,'Exempt'
UNION SELECT 'Bagger','Job Description',2,'Non-Exempt'
UNION SELECT 'Cashier','Job Description',125,'Exempt'
UNION SELECT 'Computer support specialist','Job Description',225,'Non-Exempt'
UNION SELECT 'Director of finance and accounting','Job Description',325,'Exempt'
UNION SELECT 'Retail assistant bakery and pastry','Job Description',425,'Non-Exempt'
UNION SELECT 'Retail assistant butchers and seafood specialists','Job Description',625,'Exempt'
UNION SELECT 'Stocker','Job Description',825,'Exempt'

/*Insert into Employee table*/
INSERT [dbo].[Employee]
           ([LastName]
           ,[FirstName]
           ,[Address]
           ,[City]
           ,[State]
           ,[Telephone_Area_Code]
           ,[Telephone_Number]
           ,[Employer_Information_Report_EEO_1_Classification]
           ,[Salary]
           ,[Hire_Date]
           ,[Gender]
           ,[Age]
           ,[Job_TitleID]
           )
     VALUES
           ('Glenn'
           ,'Edelman'
           ,'175_Bishop_Lane'
           ,'La_Jolla'
           ,'California'
           ,'619'
           ,'555-0199'
           ,'125'
           ,'40000'
           ,'9-15-2003'
           ,'M'
           ,'32'
           ,'1'
           )
GO
/*insert into Employee table*/
INSERT [dbo].[Employee]
           ([LastName]
           ,[FirstName]
           ,[Address]
           ,[City]
           ,[State]
           ,[Telephone_Area_Code]
           ,[Telephone_Number]
           ,[Employer_Information_Report_EEO_1_Classification]
           ,[Salary]
           ,[Hire_Date]
           ,[Gender]
           ,[Age]
           ,[Job_TitleID]
           )
     VALUES
           ('McMullen'
           ,'Eric'
           ,'763_Church_Street'
           ,'Lemon_Grove'
           ,'California'
           ,'619'
           ,'555_0133'
           ,'[Employer_Information_Report__EEO_1_Classification]'
           ,'50000'
           ,'10_01_2002'
           ,'M'
           ,'21'
           ,'2'
           )
GO


INSERT [dbo].[Employee]
           ([LastName]
           ,[FirstName]
           ,[Address]
           ,[City]
           ,[State]
           ,[Telephone_Area_Code]
           ,[Telephone_Number]
           ,[Employer_Information_Report_EEO_1_Classification]
           ,[Salary]
           ,[Hire_Date]
           ,[Gender]
           ,[Age]
           ,[Job_TitleID]
           )
     VALUES
           ('Slentz'
           ,'Raj'
           ,'123 Torrey drive'
           ,'North Clairmont'
           ,'California'
           ,'619'
           ,'555_0123'
           ,'[Employer_Information_Report__EEO_1_Classification]'
           ,'50000'
           ,'05_15_200'
           ,'M'
           ,'25'
           ,'5'
           )
GO

INSERT [dbo].[Employee]
           ([LastName]
           ,[FirstName]
           ,[Address]
           ,[City]
           ,[State]
           ,[Telephone_Area_Code]
           ,[Telephone_Number]
           ,[Employer_Information_Report_EEO_1_Classification]
           ,[Salary]
           ,[Hire_Date]
           ,[Gender]
           ,[Age]
           ,[Job_TitleID]
           )
     VALUES
           ('Broun'
           ,'Erin'
           ,'245_Parkway_Apt_2b'
           ,'Incinitas'
           ,'California'
           ,'760'
           ,'555_0100'
           ,'2'
           ,'26000'
           ,'03-01-2003'
           ,'M'
           ,'25'
           ,'5'
           )
GO


INSERT [dbo].[Employee]
           ([LastName]
           ,[FirstName]
           ,[Address]
           ,[City]
           ,[State]
           ,[Telephone_Area_Code]
           ,[Telephone_Number]
           ,[Employer_Information_Report_EEO_1_Classification]
           ,[Salary]
           ,[Hire_Date]
           ,[Gender]
           ,[Age]
           ,[Job_TitleID]
           )
     VALUES
           ('Carpenter'
           ,'Donald'
           ,'927_Second_street'
           ,'Encinitas'
           ,'California'
           ,'619'
           ,'555_0154'
           ,'[Employer_Information_Report__EEO_1_Classification]'
           ,'50000'
           ,'10_15_2003'
           ,'M'
           ,'27'
           ,'825'
           )
GO


INSERT [dbo].[Employee]
           ([LastName]
           ,[FirstName]
           ,[Address]
           ,[City]
           ,[State]
           ,[Telephone_Area_Code]
           ,[Telephone_Number]
           ,[Employer_Information_Report_EEO_1_Classification]
           ,[Salary]
           ,[Hire_Date]
           ,[Gender]
           ,[Age]
           ,[Job_TitleID]
           )
     VALUES
           ('Nancy'
           ,'Sharp'
           ,'10793 Montecino_Road'
           ,'Ramona'
           ,'California'
           ,'858'
           ,'555-0135'
           ,'125'
           ,'26000'
           ,'06-01-2003'
           ,'F'
           ,'32'
           ,'125'
           )
GO


INSERT [dbo].[Employee]
           ([LastName]
           ,[FirstName]
           ,[Address]
           ,[City]
           ,[State]
           ,[Telephone_Area_Code]
           ,[Telephone_Number]
           ,[Employer_Information_Report_EEO_1_Classification]
           ,[Salary]
           ,[Hire_Date]
           ,[Gender]
           ,[Age]
           ,[Job_TitleID]
           )
     VALUES
           ('Esquivez'
           ,'David'
           ,'10983_North_Coast_Highway'
           ,'Encinitas'
           ,'California'
           ,'760'
           ,'555_0108'
           ,'625'
           ,'32000'
           ,'07-01-2003'
           ,'M'
           ,'25'
           ,'5'
           )
/*Execute Query*/

SELECT * FROM Job_Title
SELECT * FROM Employee

SELECT
  E.LastName,
  J.Exempt_Status,
  CASE J.Exempt_Status
    WHEN 'Non-Exempt' THEN 'This Non-exempt employee is paid an hourly wage and must track their working hours'
    ELSE 'This exempt employee is not paid an hourly wage and need not track their working hours'
  END
FROM Employee AS E
JOIN Job_Title AS J
    ON J.Job_TitleID = E.Job_TitleID


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>