DEV Community

Hakan Yalitekin
Hakan Yalitekin

Posted on • Originally published at hakanyalitekin.wordpress.com on

1

SQL Telefon Numarası Sorunu

Başında 0 olan, 0 ve boşluk olan, aralarda boşluk olan telefon numaralarını formatlamak için kullanılabilir.

” 0212 123 12 12″

“0212 123 12 12”

“212 123 12 12”

“212 123 1212”

“212 1231212”

gibi formatları biçimlendirir.


...  
CASE 
     WHEN LEN(REPLACE(@TELEFON, ' ', '')) = 10 THEN LEFT(REPLACE(@TELEFON, ' ', ''), 10)
     ELSE SUBSTRING(REPLACE(@TELEFON, ' ', ''),2,LEN(REPLACE(@TELEFON, ' ', '')))
END AS Telefon

...

Enter fullscreen mode Exit fullscreen mode

Basit halinin dışına çıkmak isteyenler bu linke göz atabilir.

EDİT: Enes hocam ulaştı bana ve şöyle bir not iletti;

_ “Sizin örnek komutunuza alternatif olarak daha basit ve sade haliyle şu komut da kullanılabilir;” _


RIGHT((REPLACE(@TELEFON,' ','')),10)

Enter fullscreen mode Exit fullscreen mode

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay