2025-01-05

The obscure star-database

To play around with some obscrure naming possibilities in SQL Server I create the star-database. The name has nothing to do with the data warehouse star-schema pattern. The name is because the database is named with the star character (*).

CREATE DATABASE [*]
    ON PRIMARY ( NAME = N'star_data', FILENAME = N'L:\SSDB2019\Data\star_data.mdf', SIZE = 8MB, FILEGROWTH = 8MB )
    LOG ON ( NAME = N'star_log', FILENAME = N'L:\SSDB2019\TransLog\star_log.ldf', SIZE = 8MB, FILEGROWTH = 8MB );

The database is created on specific directory as inplicit default path using only the database name does not work. This was expected. Using the star-character as name requires me to wrap the name in [].

In the star-database I then create a star-schema.

USE [*];
GO
CREATE SCHEMA [*] AUTHORIZATION [dbo];

... and then a star-table.

CREATE TABLE [*].[*]
(
    [*] bigint NOT NULL IDENTITY (0, 2),
    [%] nvarchar(42) NULL,
    [<] int null,
    [>] int null
);
GO
ALTER TABLE [*].[*] ADD CONSTRAINT
    [PK_star] PRIMARY KEY CLUSTERED 
    ([*]) ON [PRIMARY];

The column names are are almost as obscure as the other names. And then I insert a few rows.

INSERT INTO [*].[*] ([%],[<],[>])
VALUES
    (N'række0', 1000, -1000),
    (N'rÆkke1', 10, -100),
    (N'räkke2', 237, 7);

Then I can select the table in different ways, where the syntax is quite important to the output.

SELECT [*] FROM [*].[*];
SELECT * FROM [*].[*];
SELECT COUNT(*) AS [**] FROM [*].[*];

The first two statements visually looks similar, but the [] makes quite a difference. Adding some WHERE-clauses also adds to the fun.

SELECT * FROM [*].[*] WHERE [%] LIKE '%ä%';
SELECT * FROM [*].[*] WHERE [<]<500;
SELECT * FROM [*].[*] WHERE [>]<0;

The script is in SQLAdmin Github (star_database.sql). Next round could be adding more fun with unicode...

The obscure master-database

The master database is well known. And creating a database with a similar name can make things obscure or unexpected. Playing with adding space before or after "master" is only partly possible. Adding a space after the name as [master ] does not work and gives the error "Msg 1801, Level 16, State 3, Line 8 Database 'master ' already exists. Choose a different database name.". But adding a space after like [ master] does work.

CREATE DATABASE [ master] ON  PRIMARY 
( NAME = N'master0_data', FILENAME = N'L:\SSDB2019\Data\master0_data.mdf', SIZE = 8MB, FILEGROWTH = 8MB )
LOG ON 
( NAME = N'master0_log', FILENAME = N'L:\SSDB2019\TransLog\master0_log.ldf', SIZE = 8MB, FILEGROWTH = 8MB );

Adding other characters known from other parts of a database can add to the obscure situation.

CREATE DATABASE [master.] ON  PRIMARY 
( NAME = N'master_dot_data', FILENAME = N'L:\SSDB2019\Data\master_dot_data.mdf', SIZE = 8MB, FILEGROWTH = 8MB )
 LOG ON 
( NAME = N'master_dot_log', FILENAME = N'L:\SSDB2019\TransLog\master_dot_log.ldf', SIZE = 8MB, FILEGROWTH = 8MB );
GO

CREATE DATABASE [master.dbo] ON  PRIMARY 
( NAME = N'master_dbo_data', FILENAME = N'L:\SSDB2019\Data\master_dbo_data.mdf', SIZE = 8MB, FILEGROWTH = 8MB )
 LOG ON 
( NAME = N'master_dbo_log', FILENAME = N'L:\SSDB2019\TransLog\master_dbo_log.ldf', SIZE = 8MB, FILEGROWTH = 8MB );

The script file with the obscure master databases is also in SQLAdmin Github in obscure_master_database.sql.

2025-01-01

Top-ten posts 2024

2024 was a year with fewer posts than planned - again. As each post is like a personal refined note on a specific situation this signals that I am working less with specific technical incidents. My day is more filled with long-term considerations and actions.

This is the top-ten list of my posts on the 2024 statistics.

RankMoveRank 2023TitleViewsCreated
101 SqlBulkCopy with PowerShell18502017-07-30
2+13 ISO 8601 date formatting using PowerShell3342008-08-14
3+710 Audit Log for Analysis Services2842014-01-08
4+48 Start shared HTA with PowerShell2582012-09-13
5> 6> 10 Add SQL Agent job step with tokens in output file name2382023-02-14
6+17 DBCC CHECKDB with PowerShell2102014-10-09
7> 4> 10 MSDTC Operations1172022-11-29
8> 3> 10 xp_instance_regwrite syntax1752010-09-15
9> 2> 10 Database version1242009-09-26
10-55 SQL Server Agent schedule owner982010-02-08

With a total of 39500 views in 2024 the top-ten posts is with 3748 views about 9 % of the views this year. The all time number of views is 402741.

This year there are both repeats and new posts on the top-ten. The number one post on SqlBulkCopy with PowerShell is sovereign again this year. There must be a link somewhere… I am surprised to see the post Database version as it is both rather old and on a very specific and rare subject.

Former Top-ten

My first post on this blog was published 2008-08-13, and many posts are irrelevant today. But I still think it is a good exercise to write each post as it gives me a option to review, refine and improve a description or solution.

Pages

TitleViews
DBA SQL Server Tools184
DBA Security64
DBA Litterature52
Microsoft Resources45

I think that the blog pages should be migrated to the SQLAdmin DK site. I am rewriting the entire site, and might take this migration into the rewrite.