Skip to content

Instantly share code, notes, and snippets.

@BrentOzar
Last active July 9, 2022 21:19
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BrentOzar/9b08b5ab2b617847dbe4aa0297b4cd5b to your computer and use it in GitHub Desktop.
Save BrentOzar/9b08b5ab2b617847dbe4aa0297b4cd5b to your computer and use it in GitHub Desktop.
CREATE DATABASE [٠০౦০٠];
GO
USE [٠০౦০٠];
GO
CREATE SCHEMA [٠০౦০٠];
GO
CREATE TABLE [٠০౦০٠].[٠০౦০٠]([٠০౦০٠] NVARCHAR(20), [۰০౦০٠] NVARCHAR(20), [٠০౦০۰] NVARCHAR(20), [۰০౦০۰] NVARCHAR(20));
GO
CREATE UNIQUE CLUSTERED INDEX [٠০౦০٠] ON [٠০౦০٠].[٠০౦০٠]([٠০౦০٠], [۰০౦০٠], [٠০౦০۰], [۰০౦০۰]);
GO
INSERT INTO [٠০౦০٠].[٠০౦০٠]([٠০౦০٠], [۰০౦০٠], [٠০౦০۰], [۰০౦০۰])
VALUES (N'[۰০౦০٠]', N'[۰০౦০٠]', N'[٠০౦০۰]', N'[۰০౦০۰]');
GO
CREATE VIEW [٠০౦০٠].[۰০౦০٠] AS SELECT [٠০౦০٠], [۰০౦০٠], [٠০౦০۰], [۰০౦০۰] FROM [٠০౦০٠].[٠০౦০٠];
GO
CREATE PROC [٠০౦০٠].[٠০౦০۰]
@٠০౦০٠ NVARCHAR(20),
@۰০౦০٠ NVARCHAR(20),
@٠০౦০۰ NVARCHAR(20),
@۰০౦০۰ NVARCHAR(20) AS
SELECT [٠০౦০٠], [۰০౦০٠], [٠০౦০۰], [۰০౦০۰]
FROM [٠০౦০٠].[۰০౦০٠]
WHERE [٠০౦০٠] = @٠০౦০٠
AND [۰০౦০٠] = @۰০౦০٠
AND [٠০౦০۰] = @٠০౦০۰
AND [۰০౦০۰] = @۰০౦০۰
ORDER BY [۰০౦০۰], [٠০౦০۰], [۰০౦০٠], [٠০౦০٠];
GO
EXEC [٠০౦০٠].[٠০౦০٠].[٠০౦০۰]
@٠০౦০٠ = N'[۰০౦০۰]',
@۰০౦০٠ = N'[٠০౦০۰]',
@٠০౦০۰ = N'[۰০౦০٠]',
@۰০౦০۰ = N'[٠০౦০٠]'
GO
@HannahVernon
Copy link

one step beyond with
CREATE TYPE [٠০౦০٠] from nvarchar(20)
GO
CREATE SCHEMA [٠০౦০٠];
GO
CREATE TABLE [٠০౦০٠].[٠০౦০٠]([٠০౦০٠] [٠০౦০٠], [۰০౦০٠] [٠০౦০٠], [٠০౦০۰] [٠০౦০٠], [۰০౦০۰] [٠০౦০٠]);
AND
CREATE PROC [٠০౦০٠].[٠০౦০۰]
@٠০౦০۰ [٠০౦০٠],
@٠০౦০۰ [٠০౦০٠],
@٠০౦০۰ [٠০౦০٠],
@۰০౦০۰ [٠০౦০٠] AS
AH AH! REALLY AMAZING

I really hope I never ever see something like that in the wild!

@rubyFeedback
Copy link

Could an explanation be added on top, explaining this? Google search lead to this here. :D

@pwehland
Copy link

It's actually "Fun With Unicode", not ASCII.
For rubyFeedback and others, here is the answer:

SELECT sc.name, 
	   UNICODE(SUBSTRING(sc.name, 1,1)) uc1,
	   UNICODE(SUBSTRING(sc.name, 5,1)) uc5
FROM sys.objects so
	 JOIN
	 sys.columns sc on so.object_id = sc.object_id
WHERE so.type = 'U'
  and so.name like N'%০౦০%';

@chadbaldwin
Copy link

Leaving this here since every time I try and find this from memory, I usually end up here and then can't find the blog post it came from:
https://www.brentozar.com/archive/2018/06/stupid-t-sql-tricks/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment