The INSERT code further below produced the following error within SQL Server 2019 (v15.0.2000):
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '/'
I was asked to inform you what I need to do and what is my desired result? I need to add a record to the tv_show table with the four values below and my desired result is that it runs without error. I'm autistic; so I look at language literally; so I don't know how else to answer the request.
INSERT INTO [dbo].[tv_show] ([show_key], [title], [link], [country])
VALUES ('tt3069720', 'The Amazing Race Canada', 'https://play.google.com/store/tv/show/The_Amazing_Race_Canada?id=htcXfU1OgIk&gl=US&cdid=tvseason-s6Ujv451SErs26EfxRBr5A', 'Canada')
The code below creates the table for the insert statement above. This create statement runs without error.
CREATE TABLE [dbo].[tv_show]
(
[show_key] [varchar](20) NOT NULL,
[title] [varchar](100) NULL,
[link] [varchar](300) NULL,
[last_source_id] [varchar](20) NULL,
[last_source_year] [int] NULL,
[country] [varchar](50) NULL,
CONSTRAINT [PK_SHOW_KEY]
PRIMARY KEY CLUSTERED ([show_key] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
CodePudding user response:
Your syntax seems correct. See Fiddle
One common cause of that error is when you copy the code from a text editor, a web page, etc. and try to run it in SQL server, it sometimes picks up unwanted characters that will cause the query to fail. Read more here.
Such unexpected problems can appear when you copy the code from a web page or email and the text contains unprintable characters like individual CR or LF and non-breaking spaces.