Dynamic SQL

Execute Dynamic SQL commands in SQL Server

  • Article

In some applications having hard coded SQL statements is not appealing, because of the dynamic nature of the queries being issued against the database server. Because of this sometimes there is a need to dynamically create a SQL statement on the fly and then run that command. This can be done quite simply from the application perspective where the statement is built on the fly whether you are using ASP.NET, ColdFusion or any other programming language. But how do you do this from within a SQL Server stored procedure?

2016-05-03

5,701 reads

Blogs

Daily Coping 1 Dec 2020

By

I started to add a daily coping tip to the SQLServerCentral newsletter and to...

Power BI – Hungry Median – Aggregations

By

Introduction In my last blog post, I have addressed an issue with DAX Median...

Inspector 2.4 now available

By

All the changes for this release can be found in the Github Project page...

Read the latest Blogs

Forums

is_merge_published

By dudik

I'm running the following query to get a list of my Merge Publications but...

SSIS Startup directory not found

By wburke 85918

This seems to be a common issue throughout my packages. Anywhere I try to...

What is the best way to create events from table inserts in SQL Server

By Joseph Termine

I have a SQL 20XX database in an on-premise data center that has a...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers