Tag
#sql
11 snippets.
- Snippet SQL Server: Convert Between XML and JSON Turn XML into JSON with nodes() and FOR JSON, and JSON into XML with OPENJSON and FOR XML PATH, keeping nested rows nested.
- Snippet SQL Server: Query Large XML Documents Without Timeouts Why shredding a big XML file with nodes() can take minutes, and the fixes that bring it back to seconds: no parent axis, full paths, text(), shredding once.
- Snippet SQL Server: Turn XML Into Rows with nodes() Shred an XML document into rows and typed columns with nodes() and value(), including child rows, attributes and namespaces.
- Snippet SQL Server: Find and Remove Duplicate Rows with ROW_NUMBER() Preview duplicate rows, keep one per group, and delete the rest safely.
- Snippet SQL Server: Pass a List of IDs Without Dynamic SQL Turn a comma-separated or JSON list into rows you can JOIN to, with no string concatenation or SQL injection risk.
- Snippet SQL Server: Record Changed Rows with OUTPUT INTO Capture before and after values of an UPDATE or DELETE in the same statement, so any data fix can be undone.
- Snippet SQL Server: Update or Delete Millions of Rows in Batches Change large volumes of data in small batches to avoid table locks, log growth and blocking.
- Snippet SQL Server: Safe Bulk DELETE Using JOIN Delete rows using a JOIN with a preview step to avoid accidental data loss.
- Snippet SQL Server: Update Only When Values Change Avoid unnecessary writes and locking by updating rows only when values differ.
- Snippet SQL Server: UPSERT Without MERGE Insert new rows and update existing rows safely without using MERGE.
- Snippet SQL Server: Bulk Update with JOIN Update many rows from a supplied list of IDs + values using a temp table and JOIN. Ideal for data fixes.