Untitled
Guest 338 23rd Nov, 2022
-- 1
select count(n) from dbo.Nums
where n like '%5%'
and n between 9999 and 100000
and n % 2 = 0;
-- Odpowiedź : 15840
-- 2
create table #Osoby (
Id int primary key identity(1,1),
Imie varchar(50) not null,
Nazwisko varchar(50) not null,
Data_urodzenia date,
Plec varchar(1),
Pesel varchar(11)
);
--insert into #Osoby values ('Jakub','Salega','data ur','M','twoj pesel');
--insert into #Osoby values ('xyz','xyz','1999-09-06','M','12345678901');
--insert into #Osoby values ('zyx','zyx','2015-01-02','K','12345678901');
CREATE FUNCTION dbo.PeselValidator(@peselnumb nchar(11))
RETURNS bit
AS
BEGIN
IF ISNUMERIC(@peselnumb) = 0
RETURN 0
IF LEN(@peselnumb) != 11
RETURN 0
DECLARE
@weights AS TABLE
(
Position tinyint IDENTITY(1,1) NOT NULL,
Weight tinyint NOT NULL
)
INSERT INTO @weights VALUES (1), (3), (7), (9), (1), (3), (7), (9), (1), (3), (1)
IF (SELECT SUM(CONVERT(TINYINT, SUBSTRING(@peselnumb, Position, 1)) * Weight) % 10 FROM @weights ) = 0
RETURN 1
RETURN 0
END
select * from #Osoby;
select Imie, Nazwisko, Pesel from #Osoby
where dbo.PeselValidator(Pesel) = 1;
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
- Untitled
Markup | 35 | 16 hours ago
- mega555kf7lsmb54yd6etzginolhxxi4ytdoma2rf77ngq55fhfcnyid.onion
Template Toolkit 2 | 19 | 17 hours ago
- Untitled
Markup | 45 | 1 day ago
- Untitled
Markup | 46 | 1 day ago
- Untitled
Markup | 55 | 1 day ago
- Untitled
Markup | 50 | 1 day ago
- Untitled
Markup | 47 | 1 day ago