While doing SSIS job I got an error in my create table query
在做SSIS作业时,我在create table查询中有一个错误。
Incorrect Syntax near '-' .(Microsoft SQL Server Native Client 10.0)
不正确的语法“-”(Microsoft SQL Server本机客户端10.0)
SQL statement:
SQL语句:
CREATE TABLE Staging_ACD_Precision_Queue
(
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
Partner-Center varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
I tried the above query. I guess from the error message that, the issue is in Partner-Center varchar(9)
but I failed to fix this error. Since I'm new to SSIS and SQL queries I don't know to fix the issue.
我尝试了上述查询。我想从错误信息中可以看出,问题是在合作中心varchar(9)中,但是我没有解决这个错误。因为我对SSIS和SQL查询是陌生的,所以我不知道要解决这个问题。
3 个解决方案
#1
9
You need to put square brackets around Partner-Center
, e.g. [Partner-Center]
. Embedded spaces or special characters are not allowed in field names, but you can escape them by putting the field name within square brackets.
你需要在partnercenter周围加上方括号,例如[Partner-Center]。在字段名称中不允许嵌入空格或特殊字符,但您可以通过将字段名称放入方括号中来避免它们。
CREATE TABLE Staging_ACD_Precision_Queue (
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
[Partner-Center] varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
As others have stated here, I too would like to recommend you avoid using a hyphen in the field name and go with either Partner_Center
or PartnerCenter
as the field name instead of Partner-Center
.
正如其他人在这里所说的,我也想建议您避免使用在字段名中使用连字符,并使用Partner_Center或PartnerCenter作为字段名称,而不是Partner-Center。
#2
2
SQL Server does not allow -
in bare field names. However, you can "escape" it by surrounding the field name with square brackets ([]
):
SQL Server不允许——在裸字段名称中。但是,您可以通过使用方括号([])在字段名周围“逃离”它:
CREATE TABLE Staging_ACD_Precision_Queue (
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
[Partner-Center] varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
#3
2
You can't have "-" in column names. you can do underscores. but not minus signs.
在列名中不能有“-”。你可以做强调。但不是负号。
Actually you can however you have to [ ] around column name to create with a dash and everytime you want to access you have to [var]
实际上,你可以在你想要访问的时候,在栏名周围创建一个破折号,并且每次你想要访问的时候都必须[var]
Change
改变
Partner-Center varchar(9),
to be
是
Partner_Center varchar(9),
or
或
[Partner-Center] varchar(9)
#1
9
You need to put square brackets around Partner-Center
, e.g. [Partner-Center]
. Embedded spaces or special characters are not allowed in field names, but you can escape them by putting the field name within square brackets.
你需要在partnercenter周围加上方括号,例如[Partner-Center]。在字段名称中不允许嵌入空格或特殊字符,但您可以通过将字段名称放入方括号中来避免它们。
CREATE TABLE Staging_ACD_Precision_Queue (
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
[Partner-Center] varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
As others have stated here, I too would like to recommend you avoid using a hyphen in the field name and go with either Partner_Center
or PartnerCenter
as the field name instead of Partner-Center
.
正如其他人在这里所说的,我也想建议您避免使用在字段名中使用连字符,并使用Partner_Center或PartnerCenter作为字段名称,而不是Partner-Center。
#2
2
SQL Server does not allow -
in bare field names. However, you can "escape" it by surrounding the field name with square brackets ([]
):
SQL Server不允许——在裸字段名称中。但是,您可以通过使用方括号([])在字段名周围“逃离”它:
CREATE TABLE Staging_ACD_Precision_Queue (
PrecisionQueueID int,
BucketIntervalID int,
EnterpriseName varchar(32),
AgentOrdering int,
CallOrdering int,
Description varchar(255),
ServiceLevelThreshold int,
ServiceLevelType smallint,
ForceExpandingQueue varchar(1),
Deleted varchar(1),
ChangeStamp int,
Partner varchar(4),
Center varchar(4),
[Partner-Center] varchar(9),
LOB varchar(4),
Circle varchar(4),
TypeOfBusiness varchar(4)
)
#3
2
You can't have "-" in column names. you can do underscores. but not minus signs.
在列名中不能有“-”。你可以做强调。但不是负号。
Actually you can however you have to [ ] around column name to create with a dash and everytime you want to access you have to [var]
实际上,你可以在你想要访问的时候,在栏名周围创建一个破折号,并且每次你想要访问的时候都必须[var]
Change
改变
Partner-Center varchar(9),
to be
是
Partner_Center varchar(9),
or
或
[Partner-Center] varchar(9)