久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將 SQL 表名附加到今天的日期

Append SQL table name with today#39;s date(將 SQL 表名附加到今天的日期)
本文介紹了將 SQL 表名附加到今天的日期的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我知道我可以使用以下 sp 更改 sql 表:

I understand that I can change a sql table using the follow sp:

EXEC sp_rename 'customers', 'custs'

我將如何附加它以便新表以今天的日期作為后綴?

How would I go about appending this so that the new table has today's date as a suffix?

我嘗試了以下主題的變體,但收效甚微!

I've attempt variations on the below theme with little success!!

EXEC sp_rename 'customers', 'customers +(CONVERT(VARCHAR(8),GETDATE(),3))'

非常感謝任何幫助.

推薦答案

這聽起來很糟糕!你應該評估你的設計,用名稱中的日期重命名你的表格表明您將生成許多表,每個表用于不同的日期.您可以在表格中添加一個日期列并使用它來區分數據,而不是為不同的日期創建全新的表格.

This sounds like a very bad thing to do! you should evaluate your design, renaming your tables with dates in the names suggests that you will be spawning many tables, each for a different date. You could possibly add a date column into your table and use that to differentiate the data instead of creating completely new tables for different dates.

話雖如此,您不能將表達式作為 SQL Server 中存儲過程的參數.通過嘗試將格式化日期連接到字符串customers",您試圖將表達式作為參數傳遞.

With that said, you can not have an expression as a parameter to a stored procedure in SQL Server. By attempting to concatenate the formatted date to the string 'customers', you were trying to pass an expression as a parameter.

您必須先將表達式存儲在局部變量中,然后使用該局部變量調用存儲過程:

you must store the expression in a local variable first, and then call the stored procedure with that local variable:

DECLARE @Value varchar(500)
SET @Value='customers' +(CONVERT(VARCHAR(8),GETDATE(),3))
EXEC sp_rename 'customers', @Value

這篇關于將 SQL 表名附加到今天的日期的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 国产午夜在线 | 欧美亚洲国产一区二区三区 | 国内精品伊人久久久久网站 | www成人啪啪18 | 鸡毛片 | 黄色三级在线播放 | 99国产精品99久久久久久 | 日韩毛片在线免费观看 | 色婷婷一区二区三区四区 | 欧美午夜一区二区三区免费大片 | 久久99视频精品 | 国产欧美精品一区二区色综合朱莉 | 国产成人精品综合 | 黄色亚洲 | 免费国产一区 | 中文字幕视频一区 | 日韩在线一区二区 | 亚洲欧洲激情 | 视频一区二区在线观看 | 天天干亚洲 | 在线欧美视频 | 夜夜艹天天干 | 亚洲日韩中文字幕 | 亚洲精品色| 日韩精品 | 欧美日韩美女 | 国产美女精品视频免费观看 | 日韩精品在线观看一区二区三区 | 一道本不卡 | 亚洲视频精品 | av免费网站在线观看 | 一级特黄在线 | 波多野结衣一区二区 | 夜夜操天天艹 | 超碰日韩 | 日本中文在线视频 | 欧美一级在线 | 超碰人人艹 | 婷婷国产一区二区三区 | 国产不卡一区 | 国产丝袜一区二区三区免费视频 |