In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "sql how to dynamically add fields for temporary tables", so the editor summarizes the following contents, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "sql how to dynamically add fields to temporary tables" article.
1. In the variable field, we need to use EXECUTE to execute the code as follows:
BEGIN IF OBJECT_ID ('dbo.#TempTable') IS NOT NULL DROP TABLE dbo.#TempTable CREATE TABLE # TempTable (Id INT, Item NVARCHAR) END
two。 Dynamically add a field with the current date as follows:
BEGIN DECLARE @ ColumnName NVARCHAR SET @ ColumnName ='['+ CONVERT (NVARCHAR, GETDATE) +']'--20090629 EXECUTE ('ALTER TABLE # TempTable ADD' + @ ColumnName + 'NVARCHAR (100)') END
When we're done, we execute the string of code SELECT * FROM # TempTable to see the result we want.
The above is about the content of this article on "how sql dynamically adds fields to temporary tables". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.