# Can I convert this common bit of sql into a function?

**URL:** <https://boards.straightdope.com/t/can-i-convert-this-common-bit-of-sql-into-a-function/473140>\
**Category:** Factual Questions\
**Created:** [November 17, 2008, 4:36pm UTC](https://boards.straightdope.com/t/can-i-convert-this-common-bit-of-sql-into-a-function/473140 "2008-11-17T16:36:21Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![RaftPeople](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RaftPeople](https://boards.straightdope.com/u/RaftPeople)\
**Post date:** [November 18, 2008, 2:47am UTC](https://boards.straightdope.com/t/can-i-convert-this-common-bit-of-sql-into-a-function/473140/21 "2008-11-18T02:47:51Z")

</div>

3 thoughts:

1. View
2. Write dynamic sql with any common strings defined in advance and just plugged into the dynamic sql string
3. Use a text substitution utility as a front end so you can have macro’s etc. (I use one I wrote for myself years ago, I use it for any language and any platform I’m on, kind of handy but not always a standard approach in the business world so you need to be careful about where you use it)

[Previous page](https://boards.straightdope.com/t/can-i-convert-this-common-bit-of-sql-into-a-function/473140.md?page=1)
