简体   繁体   English

如何使用冒号添加列:在使用 SQL 服务器的表中的列名中

[英]How to add column with Colon : in column name in table using SQL Server

I have two SQL server databases, DB1 and DB2 .我有两个 SQL 服务器数据库, DB1DB2

I am getting table and column names from DB1 and need to create the same in DB2 .我从DB1获取表名和列名,需要在DB2中创建它们。

While using SQL query to insert table and column in DB2 , I am getting an error使用 SQL 查询在DB2中插入表和列时,出现错误

Invalid Syntax near:附近的无效语法:

In DB1 , the table name is Person and its columns are P:ID , P:Address .DB1中,表名是Person ,它的列是P:IDP:Address

This is the query which I used to create a new table with above column names in DB2 :这是我用来在DB2中创建具有以上列名的新表的查询:

INSERT TABLE NEW_PERSON (P:Name varchar(255), P:Address varchar(255))

I got references for MySQL database but my need is for SQL Server database.我得到了 MySQL 数据库的引用,但我需要的是 SQL 服务器数据库。

Thank you in advance先感谢您

P:Name will become [P:Name] P:Name 将变为 [P:Name]

But please dont: special characters in database object names will lead to problems.但请不要:数据库 object 名称中的特殊字符会导致问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM