This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
A cord passes through one reinforced brass opening in an intact canvas panel

EXECUTE AS OWNER in Stored Procedures: Power and Pitfalls

August 29, 2011
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL Server Security

A procedure with owner rights can write to tables its caller cannot touch. Watch the identity change, and see how one careless parameter hands out too much.

Read More
A grid of four plants with its column names in one red header, beside the same rows as XML where PlantID, PlantName, Light and WaterDays repeat inside every row element

What Is XML in SQL Server: Tags, Attributes and Well-Formed Rules

August 29, 2011
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Scripts, SQL Server, SQL XML

What is XML in SQL Server? It’s plain text where every value carries its own label. This post turns four plant rows into XML with FOR XML RAW, names the parts of a document, and shows the errors SQL Server returns when a rule is broken.

Read More
A grid of two cases: when Plan A works the UPDATE runs, Plan A worked is printed and CATCH is skipped; when Plan A fails the UPDATE raises error 515, the rest of TRY is skipped and CATCH prints Plan B with error 515, severity 16, line 2

TRY CATCH Block in SQL Server: Plan A, Plan B and the Rollback

August 28, 2011
Pinal Dave
SQL Tips and Tricks
SQL Error Messages, SQL Scripts, SQL Server, SQL Transactions

A TRY CATCH block runs Plan A and falls back to Plan B when Plan A raises an error. This post shows that CATCH runs only after an error, that severity 11 is the line between a message and an error, and that one ROLLBACK undoes a nested transaction completely. Every result comes from SQL Server 2025.

Read More
Two columns of messages: errors SQL Server raises itself, 2714 and 515 at level 16 and 3701 at level 11, and errors you raise yourself with RAISERROR and THROW, 50000 and 50001 at level 16, plus a severity 10 note that is only a message

Raise Your Own Error in SQL Server: When Valid Code Breaks a Rule

August 27, 2011
Pinal Dave
SQL Tips and Tricks
SQL Error Messages, SQL Scripts, SQL Server, SQL Stored Procedure

Raise your own error in SQL Server when a valid statement breaks a rule you care about. This post shows three errors SQL Server raises itself, one error that depends on what exists in the database, and how RAISERROR and THROW turn an update of zero rows into a clear message. Every result comes from SQL Server 2025.

Read More
A function that returns a table: GetCategoryProducts takes a category, returns Assam Tea, Green Tea and Chamomile for Tea, and Cardamom, Cumin and Turmeric for Spice

Function That Returns a Table: Table Valued Functions

August 26, 2011
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Scripts, SQL Server, SQL View

A function that returns a table works like a view that takes parameters. This post builds inline table valued functions over a small product table, compares them with a view and a scalar function, uses them with CROSS APPLY, and shows the two common mistakes with parentheses. Every result comes from SQL Server 2025.

Read More
Separated brush parts with a spare metal ferrule protected in a small tin

Backing Up the Service Master Key and Database Master Keys

August 25, 2011
Pinal Dave
SQL Tips and Tricks
SQL Scripts, SQL Server, SQL Server Security

A database backup does not carry the key that opens your encrypted data. Export both keys, restore one from its file, and see why the password matters.

Read More
A table passed to a procedure in one call: the variable @List of type ClassListType holds three classes, the procedure AddClasses reads them through a READONLY parameter, and the Classes table ends with 5 rows

Pass a Table to a Stored Procedure With a Table Type

August 25, 2011
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL Scripts, SQL Stored Procedure, SQL Variable

To pass a table to a stored procedure, you create a table type and declare a parameter of that type. This post builds a type, a procedure and a call that inserts three classes at once, then a call that inserts a thousand rows, and explains four common errors. Every result comes from SQL Server 2025.

Read More
Previous 1 … 578 579 580 581 582 583 584 … 844 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com