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

更新列的腳本

Script to update a column(更新列的腳本)
本文介紹了更新列的腳本的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

表名:Citizen

Firstname       Lastname    Telephone1         Many other columns......
John             Smith      03907625212    
Andrew           Evans      0807452132    
Bill             Towny      05907122139  
Dame             Beaut      07894650569   

理想情況下應(yīng)該是這樣的:

It should ideally look like this:

Firstname       Lastname      Telephone1         Many other columns......
John             Smith       01907000001   
Andrew           Evans       01907000002  
Bill             Towny       01907000003 
Dame             Beaut       01907000004   

早些時(shí)候,有人能夠使用 select 語句提供腳本.增量創(chuàng)建記錄的腳本

Earlier, someone was able to kindly provide a script using the select statement. Script for incrementally creating records

select [First Name], 
       [Last Name], 
       [All LP Surname], 
       [All Liable Partys PIN], 
       '01907' + RIGHT('00000' + CAST(ROW_NUMBER() OVER (ORDER BY [Last Name]) AS VARCHAR), 6) AS 'Telephone1', 
       [Telephone2], 
       [Mobilephone], 
       [EmailAddress] 
FROM citizen

然而,我希望實(shí)施更改,因?yàn)槲抑荒茉谑褂蒙鲜鲞x擇腳本時(shí)查看它們.

I would however like the changes to be implemented as I can only view them if I use the above select script.

推薦答案

為此不需要 JOIN.您可以使用添加的新列的值直接從 CTE 更新.我假設(shè)您希望將 Telephone1 列設(shè)置為等于查詢的計(jì)算 Telephone1 列.代碼如下:

No JOINs are required for this. You can update directly from a CTE using the value of the new column added. I'm assuming you're wanting to set the Telephone1 column equal to the computed Telephone1 column of your query. Here's the code for this:

;With ToUpdate As
(
    Select *,
           '01907' + 
               Right('00000' + 
                   Cast(Row_Number() Over (Order By [Last Name]) As Varchar)
                , 6) 
           As NewTelephone1
    From   Citizen
)
Update  ToUpdate
Set     Telephone1 = NewTelephone1

這會(huì)將您的 citizen 表的 Telephone1 列更新為計(jì)算出的 NewTelephone1 的值.

This will update your citizen table's Telephone1 columns to be the values of the computed NewTelephone1.

這篇關(guān)于更新列的腳本的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個(gè)子標(biāo)記轉(zhuǎn)換為具有多個(gè)分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個(gè)表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計(jì)算值創(chuàng)建計(jì)算值)
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?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對(duì)?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(hào)(問題和答案的組合))
主站蜘蛛池模板: 国产精品毛片一区视频播 | 夜夜av| 中文字幕有码在线 | 日韩视频在线观看免费 | 亚洲第一天堂网 | 国产一级片免费 | 久久免费视频网站 | 午夜性视频 | 一区二区三区高清 | 超碰人人插| 国产玖玖| 亚洲综合自拍 | av久草| 午夜xxx | 国产精品一区二区不卡 | 婷婷六月激情 | 欧美日韩国产片 | 成人小视频在线观看 | 久久成人国产 | 国产精品一区二区不卡 | 福利片在线| igao视频在线 | 欧美一级欧美三级 | 午夜专区| 国产中文字幕在线 | 狠狠操综合网 | 狠狠久 | 欧美成人久久 | 精品在线一区二区 | 饥渴放荡受np公车奶牛 | 欧美在线日韩 | 精品伊人久久 | 黄色国产精品 | 午夜免费视频 | 黄色特级毛片 | 91手机在线视频 | 黄色一区二区三区 | 久草资源在线 | 夜夜操狠狠操 | 日本男人天堂 | 91成人精品一区在线播放 |