简体   繁体   English

SQL Server CLR和T-SQL存储过程是否与调用方相同?

[英]Are SQL Server CLR and T-SQL stored procedures identical to the caller?

To write some dummy stored-procedures I was wondering if I could just write them in C# since I don't know T-SQL very well. 我想知道是否可以用C#编写一些虚拟的存储过程,因为我不太了解T-SQL。

Are C# and T-SQL versions of the same procedure indistinguishable to calling code eg C++/C#/Java code using standard database library classes? 是否使用标准数据库库类将同一过程的C#和T-SQL版本与调用代码(例如C ++ / C#/ Java代码)区分开?

Yes, the caller won't know the difference. 是的,呼叫者不会知道两者之间的区别。 However, there are a few API differences: 但是,API有一些区别:


Outside of that technical answer to the Question, there are some things to consider: 除了对问题的技术回答之外,还需要考虑一些事项:

  • What specifically do you feel is easier to do in C# than in T-SQL? 您觉得在C#中比在T-SQL中更容易实现什么?
  • What exactly is being considered "dummy"? 什么才算是“虚拟”? Are you just needing a signature? 您只需要签名吗? If so, it would be far easier to do that in plain T-SQL. 如果是这样,那么在纯T-SQL中执行此操作会容易得多。 All it takes for T-SQL to do a mock stored procedure is: T-SQL进行模拟存储过程所需要做的就是:

     CREATE PROCEDURE SchemaName.ProcedureName ( @Param1name Param1Type, @Param2name Param2Type, ... ) AS SELECT CONVERT(resultField1type, NULL) AS [resultField1name], CONVERT(resultField2type, NULL) AS [resultField2name], ... ; 
  • The term "dummy" implies that these will be replaced with something else later. 术语“虚拟”意味着这些将在以后用其他东西代替。 What will they be replaced with? 它们将被替换为什么? T-SQL Stored Procedures? T-SQL存储过程? Who will write those if you don't know T-SQL? 如果您不了解T-SQL,谁来写那些?

  • If you don't know T-SQL, and you don't have anyone helping you that does know T-SQL (hence needing to make the "dummy" stored procedures in SQLCLR), then how do you know that you are structuring this solution correctly? 如果您不了解T-SQL,并且没有任何人知道T-SQL(因此需要在SQLCLR中制作“虚拟”存储过程),那么您如何知道您正在构造此结构?解决方案正确吗? You could be going in the completely wrong direction, regardless of T-SQL vs SQLCLR. 无论T-SQL与SQLCLR无关,您都可能朝完全错误的方向前进。

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

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