54 lines
1.2 KiB
Transact-SQL
54 lines
1.2 KiB
Transact-SQL
/* ------------------------------------------------------------
|
|
sql/playground.sql
|
|
Local playground for SQL Server 2025 in Docker
|
|
------------------------------------------------------------ */
|
|
|
|
-- Basic server info
|
|
SELECT
|
|
@@SERVERNAME AS ServerName,
|
|
@@VERSION AS SqlServerVersion,
|
|
SYSDATETIME() AS ServerTimeLocal,
|
|
SYSUTCDATETIME() AS ServerTimeUtc;
|
|
|
|
-- Switch to your dev database (created by seed/migrations)
|
|
IF DB_ID(N'DevDb') IS NULL
|
|
BEGIN
|
|
PRINT 'Database DevDb does not exist yet. Run: ./scripts/seed.sh and ./scripts/migrate.sh';
|
|
RETURN;
|
|
END
|
|
GO
|
|
|
|
USE DevDb;
|
|
GO
|
|
|
|
SELECT DB_NAME() AS CurrentDatabase;
|
|
GO
|
|
|
|
-- Check if example table exists and query it
|
|
IF OBJECT_ID(N'dbo.Customer', N'U') IS NULL
|
|
BEGIN
|
|
PRINT 'Table dbo.Customer does not exist yet. Run: ./scripts/migrate.sh';
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
PRINT 'dbo.Customer exists. Running sample queries...';
|
|
|
|
SELECT TOP (10) *
|
|
FROM dbo.Customer
|
|
ORDER BY CustomerId DESC;
|
|
|
|
SELECT COUNT(*) AS CustomerCount
|
|
FROM dbo.Customer;
|
|
END
|
|
GO
|
|
|
|
/* ------------------------------------------------------------
|
|
Scratch area (write your own queries below)
|
|
------------------------------------------------------------ */
|
|
|
|
-- Example:
|
|
-- SELECT TOP (100) *
|
|
-- FROM dbo.Customer
|
|
-- ORDER BY CustomerId;
|
|
|