首页 \ 问答 \ 使用C#更改SQL Server主键(Change SQL Server primary key using C#)

使用C#更改SQL Server主键(Change SQL Server primary key using C#)

我需要更改SQL Server表中的列类型。

我需要使用脚本或C#来做。

原始数据类型是integer ,新类型是varchar(50)

我可以使用这个SQL脚本来做到这一点:

ALTER TABLE confezionamento ALTER COLUMN partnumber varchar(50) 

但问题是这个列是一组主键。

当我尝试执行时,发生错误,因为PK_CONFEZIONAMENTO正在使用该列。

如何在不访问SQL Server Management Studio的情况下执行此操作?


I need to change a column type in a SQL Server table.

I need do it using a script or C#.

The original datatype is integer and the new type is varchar(50).

I can do it using this SQL script:

ALTER TABLE confezionamento ALTER COLUMN partnumber varchar(50) 

but the problem is that this column is in a set of primary keys.

When I try do execute, an error occurred because PK_CONFEZIONAMENTO is using the column.

How I can do it without access to SQL Server Management Studio?


原文:https://stackoverflow.com/questions/29868873
更新时间:2022-10-11 22:10

最满意答案

我想你可能会把ChangeSets和RevisionHistory混在一起。 如果您要跟踪Rally Artifact上的Revisions,您应该查看RevisionHistory集合。 Rally的源代码连接器使用ChangeSets将源代码提交与Rally中的各种工件相关联。

你可能会找到这个答案:

RevisionHistory和Revisions

有助于在SOAP中处理RevisionHistory。 该示例适用于用户故事,但同样适用于测试用例。

遗憾的是,您无法在RevisionHistory上进行查询,因此您需要检索可能与您的搜索匹配的所有测试用例,并对SOAP客户端中的TestCase创建者进行过滤。 您需要检查修订版0的作者属性:

0 Original revision 2013-Feb-18 09:23:11 AM America/Denver Sam Tester

并验证它符合您的标准。

只是一个单挑,特别是如果你刚刚开始构建集成,我强烈建议使用Rally的.NET REST SDK而不是SOAP。

REST更强大,性能更高,Webservices API 1.43是获得SOAP支持的最终API版本,而1.43在弃用之前大约需要9个月(截至2013年9月)。 Webservices 2.x仅支持REST,因此使用REST对于任何希望新Web服务功能向前发展的人来说都是必不可少的。


I think you might be mixing up ChangeSets with RevisionHistory. If you're looking to track Revisions on a Rally Artifact, you should look at the RevisionHistory collection. ChangeSets are used by Rally's source code connectors to associate source code commits to various artifacts in Rally.

You might find this answer:

RevisionHistory and Revisions

Instructive for dealing with RevisionHistory in SOAP. The example is for User Stories, but is equally applicable to Test Cases.

Unfortunately, you can't query on RevisionHistory, so you would need to retrieve all the Test Cases that could potentially have matches against your search, and do the filtering for the TestCase creator in your SOAP client. You would need to check the Author attribute for Revision 0:

0 Original revision 2013-Feb-18 09:23:11 AM America/Denver Sam Tester

And verify that it matches your criteria.

Just a heads-up, especially if you're just getting started with building your integration, I'd highly recommend using one of Rally's .NET REST SDK instead of SOAP.

REST is more robust, more performant, and, Webservices API 1.43 was the final API release to have SOAP support, and 1.43 has about 9 months to go (as of 9/2013) before deprecation. Webservices 2.x is REST-only, so using REST will be essential to anyone wanting new Webservices features moving forward.

相关问答

更多
  • 由于SOAP在HTTP协议中具有体系结构,因此可以使用数十种商业和开源工具来执行负载和可伸缩性测试。 你需要做的是确保你选择的任何工具都能满足正确运用你的界面的技术需求,这与你的内部技能非常匹配,并且包含你需要确定测试工作成败的报告。 如果你得到的工具在三个方面都不匹配,那么你可能已经购买了市场上最昂贵的工具,并雇用了最昂贵的咨询表格来使用它们......类似或者像用钉子而不是使用适当的工具(锤子)。 目前市场上的大多数商业工具都有租赁/租赁选项以供短期使用,然后还有开源品种。 每个工具都具有与核心任务相关 ...
  • 通过将web.xml添加到WEB-INF目录以及以下内容来解决该问题:
    问题出在发布方法上 Endpoint.publish("http://192.168.1.13:8080/WS/TestSoap", new BalanceImp()); 尝试使用在源应用程序(发布者)中使用eclipse创建和发布Web服务的向导。 该向导将通过添加来更改web.xml Apache-Axis Servlet AxisServlet ...
  • 如果没有首先生成有效的WSDL,则无法调用您的服务。 根据您的错误,Eclipse认为您错过了一个Operation(方法)。 发生这种情况是因为您的Person类没有任何方法。 因此,没有操作。 幸运的是,对于你设置它的方式,你不需要经历并生成基于Person的WSDL。 但是,您的Search类使用Person,WSDL应该生成没有问题。 这是您需要的唯一WSDL。 现在为您的searchBySurname方法,根据您拥有的内容,这似乎不正常。 我的想法(我从这里调试):( a)你的搜索源看起来很好,所 ...
  • 您可以使用Delay类型测试步骤,您需要在运行步骤之前或在现有步骤之间等待。 有关更多详细信息,请参阅SoapUI的文档 。 顺便说一下,我假设目标是多次运行测试用例,并将应用程序的负载测试作为Delay来影响统计数据。 You can use Delay type test step where you need to wait such as before running the steps or in between the existing steps as well. For more detai ...
  • 不,它有效。 不知道发生了什么,但我没有改变任何东西,但是今天早上标题工作正如预期的那样,这是请求
  • 我使用Axis 2来创建SOAP Web服务,因为我的WSDL没有生成,因为只要我将Web服务引擎从Axis 2更改为Axis,就会生成wsdl。 I was using Axis 2 for creating SOAP web service, because of that my WSDL was not generating since as soon as I changed the Web service engine from Axis 2 to Axis , wsdl got generate ...
  • 不推荐直接与SOAP通信的方法,现在通过添加服务引用成功地将其与.NET控制台应用程序一起使用。 可以获取,插入记录。 Deprecated the methodology of communicating directly with SOAP, instead now successfully using it with .NET console application by adding service reference. Can fetch, insert records.
  • 有一个文件joomla_root\libraries\joomla\user\user.php 登录表单中的数据最终会出现。 在该文件中有一个函数bind 。 我认为您必须在那里挂钩您的Web服务请求。 如果这对您不起作用,我建议您加入joomla开发列表 。 那里有很多joomla专家。 there is a file joomla_root\libraries\joomla\user\user.php The data from login form eventually comes there. In ...
  • 我想你可能会把ChangeSets和RevisionHistory混在一起。 如果您要跟踪Rally Artifact上的Revisions,您应该查看RevisionHistory集合。 Rally的源代码连接器使用ChangeSets将源代码提交与Rally中的各种工件相关联。 你可能会找到这个答案: RevisionHistory和Revisions 有助于在SOAP中处理RevisionHistory。 该示例适用于用户故事,但同样适用于测试用例。 遗憾的是,您无法在RevisionHistory上 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)