[英]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有一些区别:
NVARCHAR(MAX)
, VARBINARY(MAX)
, and XML
) cannot have default values in SQLCLR objects. NVARCHAR(MAX)
, VARBINARY(MAX)
和XML
)在SQLCLR对象中不能具有默认值。 (Microsoft Connect suggestion to vote for, perhaps: Support default parameter values for NVARCHAR(MAX), VARBINARY(MAX), and XML types in SQLCLR objects ) SMALLDATETIME
SMALLMONEY
CHAR
VARCHAR
TEXT
NTEXT
IMAGE
Outside of that technical answer to the Question, there are some things to consider: 除了对问题的技术回答之外,还需要考虑一些事项:
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,谁来写那些?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.