10ecdfa2e4
Adds the SQL Server Data Tools project for the fuchs_fds database — tables, table types, functions and stored procedures that the backend calls (e.g. fds__getInvoice, fds__merge_bankingtransactions, fds__tt__bankingtransactions, fds__admin_getReportCatalog, fis_* auth). Build/model caches (bin, obj, *.dbmdl, *.jfm, *.user) are git-ignored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
897 B
Transact-SQL
43 lines
897 B
Transact-SQL
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date, ,>
|
|
-- Description: <Description, ,>
|
|
-- =============================================
|
|
CREATE FUNCTION [dbo].[ott_b10]
|
|
(
|
|
@string varchar(10)
|
|
)
|
|
RETURNS int
|
|
AS
|
|
BEGIN
|
|
DECLARE @RET int;
|
|
|
|
|
|
DECLARE @str VARCHAR(10) = REVERSE(LOWER(@string));
|
|
WITH Split(stpos,endpos) AS(
|
|
SELECT 1 AS stpos, 2 AS endpos
|
|
UNION ALL
|
|
SELECT endpos, endpos+1
|
|
FROM Split
|
|
WHERE endpos <= LEN(@str)
|
|
)
|
|
, c as (
|
|
SELECT
|
|
'character' = SUBSTRING(@str,stpos,COALESCE(NULLIF(endpos,0),LEN(@str)+1)-stpos)
|
|
,'charindex' = stpos
|
|
FROM Split
|
|
)
|
|
, s as (
|
|
SELECT
|
|
*
|
|
,'num' = ASCII(character) - ASCII('a') + 1
|
|
,'fac' = POWER(26,([charindex] -1))
|
|
,'val' = POWER(26,([charindex] -1)) * (ASCII(character) - ASCII('a') + 1)
|
|
FROM c
|
|
)
|
|
select @RET = SUM([val]) FROM s;
|
|
|
|
RETURN @RET;
|
|
|
|
END |