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

如何在 SQL Server 2016 中創建寬表?

How do I create a wide table in SQL server 2016?(如何在 SQL Server 2016 中創建寬表?)
本文介紹了如何在 SQL Server 2016 中創建寬表?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

使用此代碼(*),在 SQL 中創建寬表讓我不斷發送:

With this code(*), the creation of a wide table in SQL keeps me sending this:

Msg 1702, Level 16, State 1, Line 11
CREATE TABLE failed because column '2010/12/01' in table 'PriceToBookFinalI' exceeds the maximum of 1024 columns.

使用[樣式]去

CREATE TABLE [dbo].[PriceToBookFinalI]
    (DocID int PRIMARY KEY,
    [2006/12/29][Money],
    [2007/01/01][Money],
    ...
    SpecialPurposeColumns XML COLUMN_SET FOR ALL_SPARSE_COLUMNS);  

GO

(2614 columns)

尋找好的提示!

這里是我想導入到寬表的背景數據集

Here is the background set of data I want to import to my wide table

推薦答案

對此的解決方案是規范化您的設計.即使您可以將其放入 1024 限制,您的設計也不是一個好主意.例如,如果您想知道 DocID 每月更改的平均金額怎么辦.在這個模型中編寫這將是一場噩夢.

The solution for this is to normalize your design. Even if you could fit it into the 1024 limit, your design is not a good idea. For example, what if you wanted to know the average amount a DocID changed per each month. That would be a nightmare to write in this model.

試試這個.

CREATE TABLE dbo.PriceToBookFinalI (
                                     DocID INT PRIMARY KEY,
                                     SpecialPurposeColumns XML COLUMN_SET FOR ALL_SPARSE_COLUMNS
                                   );


CREATE TABLE dbo.PriceToBookFinalMoney (
                                         DocID INT,
                                         DocDate DATE,
                                         DocAmount MONEY,
                                         CONSTRAINT PK_PriceToBookFinalMoney
                                           PRIMARY KEY CLUSTERED
                                           (
                                             DocID,
                                             DocDate
                                           )
                                       );

您可以輕松地將帶有 SpecialPurposeColumns 的表連接到帶有每個 DocID 的日期和金額的表.如果需要,您仍然可以將日期轉換為上面提供的格式.將日期作為列中的值可讓您更靈活地使用數據、提高性能并自然地處理更多日期.

You can easily join the table with the SpecialPurposeColumns to the table with the dates and amounts for each DocID. You can still pivot the dates if desired into the format you provided above. Having the date as a value in a column gives you much more flexibility how you use the data, better performance, and naturally handles more dates.

這篇關于如何在 SQL Server 2016 中創建寬表?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 日韩av一区二区在线观看 | 精品视频在线观看 | 91免费在线| 亚洲成人一级片 | 亚洲精品视频免费观看 | 嫩草研究影院 | 国产精品爱久久久久久久 | 亚洲精品久久久蜜桃网站 | 欧产日产国产精品视频 | 久久精品免费一区二区 | 国产色网站 | 午夜天堂精品久久久久 | 日韩在线资源 | 国产不卡在线观看 | 欧美一二三 | 午夜网| 91免费观看国产 | 九九热免费在线观看 | 免费人成在线观看网站 | 久久亚洲一区二区三 | 精品欧美一区二区三区久久久 | 欧美日韩成人 | 国产一区二区三区免费观看视频 | 美女爽到呻吟久久久久 | 欧美视频1区 | 一区二区三区国产 | 日韩成人在线观看 | 欧美一区二区激情三区 | 天堂av中文在线 | 精品欧美一区二区三区久久久 | 一级黄色在线 | 国产乱码精品1区2区3区 | 欧美aⅴ | 日韩精品在线网站 | 久久综合伊人 | 羞羞色影院 | 天天搞天天操 | 亚洲一区二区三区免费视频 | 欧美一区二区大片 | 天天爽一爽 | 久久久久久亚洲欧洲 |