I am trying to write a SQLCLR function that takes DateTime2 as input and returns another DateTime2. Based on this post, I changed the parameter as a C # type of DateTime type, giving me the necessary level of accuracy. However, since the input may be null, I would like it to be a DateTime ?; return type also.
using System; using Microsoft.SqlServer.Server; namespace SqlServer.Functions { public class UserDefinedFunctions { [SqlFunction(DataAccess = DataAccessKind.None)] public static DateTime? GetLocalTimeFromGMT(DateTime? dateTime) { if (dateTime.HasValue) return DateTime.SpecifyKind(dateTime.Value, DateTimeKind.Utc).ToLocalTime(); else return (DateTime?)null; } } }
The problem is that when I try to deploy, I get the following error:
Error 1 Cannot find the type "Nullable`1" because it does not exist or you do not have permission. SqlServer.Functions
I am using Sql Server 2008 and Visual Studio 2008.
, Visual Studio 2008 SQLCLR , SQL Server 2008, Nullable Types. Connect item , , Visual Studio 2010.
, Connect, Visual Studio, System.Core System.Xml.Linq SQLCLR, . .
Source: https://habr.com/ru/post/1747393/More articles:Using PHP to get the source code for the URL, I have to log in to get - httpauto-import packages through a project in eclipse - eclipsejavascript line difference - javascriptRijndael ruled: breaking off long text - rijndaelmanagedDjango AND.htaccess overwrite / redirect, is this possible? - djangoSQLCLR and DateTime2 - c #Processing a database queue across multiple threads - design tips - multithreadingphp for loop variable names - variablesHow to check if javascript function from silverlight exists - silverlightError handling in T-SQL scalar function - functionAll Articles