Dear,
Try to build an C# CLR method , and call it from SQL , Sample :
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString GeregorianDate(SqlString s)
{
string hijriDate = s.ToString();
return HijriToGreg(hijriDate);
}
public static string HijriToGreg(string hijri)
{
DateTime tempDate = DateTime.ParseExact(hijri,"yyyy-MM-dd",
new System.Globalization.CultureInfo("ar-SA"));
return tempDate.ToString("yyyy/MM/dd", new System.Globalization.CultureInfo("en-US").DateTimeFormat);
}
};
Deploy the code and then go to he sql managment studio under ypour database--> select programiltry-> select assembly --> right click new assemply and referee to your deployed dll
then you have to enable CLR in SQL :
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
then create scaler function with your parameters
ALTER FUNCTION [dbo].[GeregorianDate](@date [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [GeregorianDate].[UserDefinedFunctions].[GeregorianDate]
then you have to call this function like :
select [dbo].[GeregorianDate]('01/01/1433')
regards
Abraheem Abulubbad