T-SQL

Technical Article

Using Dynamic SQL in Stored Procedures

  • Article

Dynamic SQL allows stored procedures to “write” or dynamically generate their SQL statements. The most common use case for dynamic SQL is stored procedures with optional parameters in the WHERE clause. These are typically called from reports or screens that have multiple, optional search criteria. This article describes how to write these types of stored procedures so they execute well and resist SQL injection attacks.

★ ★ ★ ★ ★ ★ ★ ★ ★ ★

You rated this post out of 5. Change rating

2011-03-22

7,301 reads

Blogs

Dazzling Stuff in Databricks (SQL) – Qualify

By

Once upon a time I had a series about some cool stuff in Snowflake:...

Advice I Like: Overnight Success

By

“Most overnight successes – in fact any significant successes – take at least 5...

A CLR Assembly Broke My Availability Group

By

Sounds scary! Did I get your attention?

Read the latest Blogs

Forums

Layanan Resmi BCA KCU BLITAR Telp:0817°825°533

By layanan_Bca88

Telp/Wa 62817825533 Jl. Cempaka No.17, Sukorejo, Kec. Sukorejo, Kota Blitar, Jawa Timur 66111

Kantor Resmi BCA KCU JEMBER Telp:0821°7555°651

By m4rt1n4

Telp/Wa 628217555651 Jl. Gajah Mada No.14-18, Kelurahan Jember Kidu, Jember Kidul, Kec. Kaliwates, Kabupaten...

Why Successful SQL Server Backups Are Not Enough

By Almighty

Comments posted to this topic are about the item Why Successful SQL Server Backups...

Visit the forum

Question of the Day

Adding Bits II

I have a table, dbo.bittest, where I am testing an application response. This has this structure:

CREATE TABLE [dbo].[BitTest]
(
[insertdate] [datetime] NULL CONSTRAINT [DF__BitTest__insertd__300F11AC] DEFAULT (getdate()),
[a] [bit] NULL
) ON [PRIMARY]
GO
My application runs this code:
INSERT dbo.BitTest
(
    insertdate,
    a
)
VALUES
(DEFAULT, true)
GO

See possible answers