SQL CLR 中的存储过程 [英] stored procedure in SQL CLR

查看:27
本文介绍了SQL CLR 中的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 SQLCLR 中使用 C# 编写存储过程?

How do you write a stored procedure using C# in SQLCLR?

目前我正在使用 SQL Server Management Studio,我使用 T-SQL 编写存储过程,例如 create proc sp_item as .....

Currently I am using SQL Server Management Studio and I write stored procedures using T-SQL such as create proc sp_item as .....

推荐答案

参见:

基本上,有一些 Visual Studio 模板可让您开始使用 SQL CLR 项目.填写空白,编写实际代码,您甚至可以直接从 Visual Studio 中将这些 CLR 程序集部署到 SQL Server.

Basically, there are Visual Studio templates which allow you to get started with SQL CLR projects. Fill in the blanks, write your actual code, and you can even deploy those CLR assemblies into SQL Server directly from within Visual Studio.

提醒一句:我不会在 SQL CLR 存储过程中进行基于集合的更新和插入等操作 - 为此,T-SQL 存储过程明显更好更快.

One word of caution: I would refrain from doing set-based updates and inserts and stuff like that in a SQL CLR stored proc - for that, T-SQL stored procs are just plain better and faster.

SQL-CLR 非常适合扩展 SQL Server 的字符串操作、日期处理、调用能力,例如网络服务或其他东西.我建议反对尝试用 C# SQL CLR 存储过程替换所有 T-SQL 存储过程仅仅因为你可以仅仅因为它很酷 -为正确的工作使用正确的工具!集合上的大量操作最好留给 T-SQL.

SQL-CLR is great to extend SQL Server with stuff like string manipulation, date handling, ability to call e.g. web services or other stuff. I would recommend against trying to replace all T-SQL stored procs with C# SQL CLR stored procs just because you can or just because it's cool - use the right tool for the right job! Mass operations on sets are better left to T-SQL.

这篇关于SQL CLR 中的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆