【问题标题】:How to update a table concatenating the strings in two columns?如何更新连接两列中的字符串的表?
【发布时间】:2019-02-27 14:01:54
【问题描述】:

我想更新一列,将其设置为一列中字符串的串联 + 文件扩展名(在本例中为“.AVI”)。

我尝试了以下方法,但它影响了 0 行;我知道有些记录的 Video_Name 值为“FALSE”。

任何想法我做错了什么?谢谢!

declare @creativity varchar
update [UK_Telco_Pressure_2018Q3_2019-02-26 W6] 
set Video_Name=concat(@creativity,'.AVI') where Video_Name = 'false' and
@creativity=Creativity

【问题讨论】:

  • 您的服务器是否设置了区分大小写的排序规则?在这种情况下 'FALSE' != 'false'
  • @MatthewEvans 不,不区分大小写
  • @creativity 的值为NULL。你想做什么?样本数据和期望的结果真的很有帮助。
  • @GordonLinoff 我希望变量 creative 是 Creativity 列中包含的字符串

标签: sql sql-server stored-procedures string-concatenation


【解决方案1】:

我希望是这样的:

declare @creativity varchar(255);  -- length is really important

set @creativity = <some value goes here> ;  -- value is really important

update [UK_Telco_Pressure_2018Q3_2019-02-26 W6] 
    set Video_Name = concat(@creativity, '.AVI')
    where Video_Name = 'false' and
          Creativity =  @creativity;

或者你只是想要:

update [UK_Telco_Pressure_2018Q3_2019-02-26 W6] 
    set Video_Name = concat(creativity, '.AVI')
    where Video_Name = 'false' ;

【讨论】:

    猜你喜欢
    • 2017-11-10
    • 2020-05-26
    • 2018-11-14
    • 2017-04-24
    • 1970-01-01
    • 2021-10-19
    • 2022-12-16
    • 2020-08-23
    • 1970-01-01
    相关资源
    最近更新 更多