SQL服务器问题 [英] Problem with SQL server
问题描述
我正在使用MyLittleAdmin来管理云端的SQL Server数据库。
我生成了一个字段,其名称用括号括在表格中
例如,它在这样的表格中查找。
ValorComision(金钱,非空)
Atraso(int,null)
[PagosExtra](钱,空)
问题是我不可能在那个领域工作。
如果我想做一个简单的搜索示例。
SELECT [PagosExtra]来自IG_COBRO_ALQUILERES
消息207,级别16,状态1,行号1
无效的列名称'PagosExtra'。
我有什么尝试过:
如何更改字段名称或删除它以替换它并跳过问题?
I'm using MyLittleAdmin to manage a SQL Server database in the cloud.
By mistake I have generated a field whose name was enclosed in brackets in a table
For example It looks in the table like this.
ValorComision (money, not null)
Atraso (int, null)
[PagosExtra] (money, null)
the problem is that it is impossible for me to work with that field.
If I would like to do a simple search for example.
SELECT [PagosExtra] FROM IG_COBRO_ALQUILERES
Msg 207, Level 16, State 1, Line number 1
Invalid column name 'PagosExtra'.
What I have tried:
How could i change the name to the field or delete it to replace it and skip the problem?
推荐答案
首先找出SQL如何命名:我使用SSMS,我确定MyLittleAdmin会有一些东西类似。
在SSMS中,您可以右键单击表名并使用脚本表作为...新查询窗口 - 这将为您提供该列的sql名称。这可能是[[PagosExtra]]]
如果你有这个,请将其输入:
Start by finding out how SQL thinks it's named: I use SSMS, bit I'm sure MyLittleAdmin will have something similar.
In SSMS you can right click the table name and use "Script table as ... new query window" - that will give you the "sql name" for the column. It's probably [[PagosExtra]]]
When you have that, feed it into this:
EXEC sp_Rename 'MyTable.[[PagosExtra]]]', 'PagosExtra' , 'COLUMN'
并执行它。
你可能会收到一个警告,它可能会破坏脚本,但它应该是正常的现在名字。
and execute it.
You'll probably get a warning that it might break scripts, but it should be a "normal" name now.
另一个想法是更改字段/列名称并删除不必要的方括号。
注意:我什么都不知道关于MyLittleAdmin,但在MS SQL Management Studio中,您始终可以使用 alter table command [ ^ ]至修改列名 [ ^ ] 。我相信逻辑是一样的。
Another idea is to change field/column name and remove unnecessary square brackets.
Note: i know nothing about MyLittleAdmin, but in MS SQL Management Studio you can always use alter table command[^] to modify column name[^]. I believe that logic is the same.
这篇关于SQL服务器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!