开发者

What considerations go with SQL/CLR integration when database is live and changes are frequent?

I just now for the very first time made a CLR function and deployed it into a database, and after reading a little about how it works, think it's a good option for a C# programmer like me.

My question: if I press "control F5" and let VS do it's magic deploy of my user defined functions, etc, to my database -- what if there are current connections to that database using the previous version?

My hope is that it would be seamless.

If it would cause a query in progress to return an error开发者_StackOverflow中文版, I have to wait until the time when a proper development environent can be used.

EDIT: I decided to put in what I'm going to use this for first based on feedback last time I posted with this tag.

I don't want to maintain logic in two languages, so I'm going to convert the following to C#:

CREATE FUNCTION [dbo].[tousd] 
(@Currency char(3), @Amount money)
RETURNS money
AS
BEGIN
declare @Return money
if(@Currency = 'USD')
    return @Amount * 1.0
else if(@Currency = 'EUR')
    return (@Amount * 1.3065)
else if(@Currency = 'GBP')
    return (@Amount * 1.5552)
else if(@Currency = 'CAD')
    return (@Amount * 0.9789)
else if(@Currency = 'AUD')
    return (@Amount * 0.9613)
else
    return 0.0
return @Return
end

Thanks in advance, Aaron


Do not convert tsql to C# just becasue you are more comfortable with it. Databases are optimized to work best with SQL not C#. CLRs are only available to do things that SQL cannot do. If you can do it in SQl, do it in SQL.

Do not do any more work until you have a real dev environment. Mucking around with stuff people are actually using is unprofessional and dangerous to the data and can quickly lose your customers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜