Запах SELECT'а. Обнаружение CODE SMELL до отправки T-SQL кода на прод

Взгляд на экосистему SQL-разработки под MS SQL SERVER через призму контроля качества кода. Обзор существующих инструментов, описание самостоятельной наработки для линтинга T-SQL кода.

https://habr.com/ru/articles/1036340/

#tsql #code_smell #static_analysis #opensource #db #sqlproj #ssdt #dacfx #scriptdom #codesmell

Запах SELECT'а. Обнаружение CODE SMELL до отправки T-SQL кода на прод

Оглавление I Трудности селектописательства II Доступные средства III Защита от CODE SMELL IV Испытания P.S. TLDR Написал свой вариант T-SQL линтера для работы и выложил на GitHub: T-SQL плагин с...

Хабр
No more excuses: AI-powered assistants are in SSMS, VS Code, and Fabric | Microsoft Fabric Blog | Microsoft Fabric

You like writing T-SQL. You&#8217;re good at it. Or maybe you’re not. But let&#8217;s be honest—there are days when you&#8217;d rather not write that same GROUP BY clause for the hundredth time or spend twenty minutes deciphering a stored procedure someone wrote in 2014. Good news: AI-powered assistants are now available wherever you write SQL &hellip; <p class="link-more"><a href="https://blog.fabric.microsoft.com/en-us/blog/no-more-excuses-ai-powered-assistants-are-in-ssms-vs-code-and-fabric/" class="more-link">Continue reading<span class="screen-reader-text"> &#8220;No more excuses: AI-powered assistants are in SSMS, VS Code, and Fabric&#8221;</span></a>

Database Instructions - GitHub Copilot in SQL Server Management Studio (Preview)

Learn how to use database instructions with GitHub Copilot in SQL Server Management Studio (SSMS).

TSQL Problem:
Let's say you've got one or more scalar values that are VARCHAR 'strings' and you want to determine if they can be typed more appropriately.

For example '16:16:34.6733333' is data type TIME. It's easy to examine the value manually to make that determination. But how would you do it programatically (via TSQL)?

I've tried casting the VARCHAR as different types. TRY_CAST is successful for some data types. How would I know which one is 'right'?

#SQLHelp
#SQLServer
#SQL
#TSQL

Строковые константы в MS SQL

Строковые константы в MS SQL кажутся очень простыми в использовании. Но эта простота не всегда очевидна и порой приводит к тяжело выявляемым ошибкам в коде. По этой причине данная статья может оказаться полезной не только новичкам, но и тем, кто уже использует T-SQL в своей работе. Документация явно описывает два типа констант: обычные строковые и юникодные. Но на самом деле ситуация несколько сложнее, что и будет рассмотрено ниже.

https://habr.com/ru/articles/1001668/

#sql_server #sql #tsql

Строковые константы в MS SQL

Строковые константы в MS SQL кажутся очень простыми в использовании. Но эта простота не всегда очевидна и порой приводит к тяжело выявляемым ошибкам в коде. По этой причине данная статья может...

Хабр
OPENROWSET and External Tables for Fabric SQL Databases (Preview) | Microsoft Fabric Blog | Microsoft Fabric

Data Virtualization (Preview) for Fabric SQL Databases, enable you to query, analyze, and ingest OneLake data (CSV, Parquet, JSON) without moving or duplicating it. Data Virtualization brings to Fabric SQL Database the same set of capabilities already available on Azure SQL Database, Azure SQL Managed Instance and SQL Server, customers can now use OPENROWSET and &hellip; <p class="link-more"><a href="https://blog.fabric.microsoft.com/en-us/blog/openrowset-and-external-tables-for-fabric-sql-databases/" class="more-link">Continue reading<span class="screen-reader-text"> &#8220;OPENROWSET and External Tables for Fabric SQL Databases (Preview)&#8221;</span></a>

I spent some time writing up how to #unittest the creation and changing of #sql database components in #Microsoft #SqlServer 's #TSql . It's useful in restricted environments that won't allow other development tools that normally could conduct unit tests.
https://www.patreon.com/posts/148232620

#TodayILearned about table-valued scalar functions in Microsoft #TSql and why I should care.

These can be used in a view. If you need to run a procedure to calculate parts of the output, but use a middleware that is incapable of calling functions directly, scalar functions are your next best bet.

If they return their value as a table, you can "join" them to the main rowset in the view using the operations "cross apply" (which behaves like inner join) and "outer apply" (like outer join).

#TodayILearned that Microsoft #TSql does NOT automatically shave off the trailing spaces of a char-typed value when reading it from a data table and inserting it into a varchar-typed column of a different table. You have to trim it or convert it explicitly. Char data types aim to preserve their padding.

Do you write a lot of paper checks? (I don't--typically it's just one per month.) If so, do you screw up the year when writing in the date for the first few weeks/months of the new year?

This is my TSQL version of that. I'm off to a good start. 🙄

#TSQL
#SSMS
#NewYear