Skip to content

tokenizing column name starts with a number #79

Answered by bruce-dunwiddie
cptb asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I think this is a nonissue, and I'll explain why.

This is not valid TSQL:

CREATE TABLE dbo.RoadLayer
(
	1st_surface VARCHAR(MAX),
	2nd_surface VARCHAR(MAX)
);
Incorrect syntax near '1'.

To create the table structure that you're describing, you have to use escape syntax:

CREATE TABLE dbo.RoadLayer
(
	[1st_surface] VARCHAR(MAX),
	[2nd_surface] VARCHAR(MAX)
);

But even once the table is created, while your example TSQL statement passes syntax checks, meaning that it's technically valid TSQL, it does not return the result that you're describing.

INSERT INTO dbo.RoadLayer([1st_surface], [2nd_surface]) VALUES ('first', 'second');

SELECT 1st_surface, 2nd_surface FROM dbo.RoadLayer;

Whi…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@cptb
Comment options

Answer selected by cptb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
nonissue Issue resolved without code change needed
2 participants