Select the product you need help with
INF: How to Create Dynamic Table Names in SQL ServerArticle ID: 175850 - View products that this article applies to. This article was previously published under Q175850 SUMMARY
If you need a temporary table to persist across non-nested stored
procedures and then you want to drop the temporary table when you no longer
need it, you can dynamically create permanent tables in your code. This
article provides an example of this procedure.
MORE INFORMATION
You can use the following code to create a dynamic table name in SQL
Server:
Notice that you can enhance this further if you need more than milliseconds precision (that is, if you need to create more than one table in the same millisecond) by adding username, spid(@@spid) or other data as part of the table name. You can use part of the code above to strip unwanted characters from a string. For example, assuming you have the string "De La Hoya", you can use the WHILE loop above to get a resulting string of "DeLaHoya" Properties | Article Translations
|


Back to the top








