更新具有不同信息的字段

时间:2011-07-28 21:19:53

标签: sql

SELECT clientLastName__c, clientFirstName__c, clientID__c, Category_ID__c, 
    ID AS Incident__c, OwnerId, SystemTypeDesc as taskDescription__c
FROM process.dbo.vw_NewHireProcess
WHERE System_Type__c IS NOT NULL`

我不确定如何使用特定值更新OwnerId字段,但我不想更改列的名称。

4 个答案:

答案 0 :(得分:1)

您需要更改值,但这是UPDATE语句的布局:

UPDATE yourTableName
   SET OwnerId = yourValue
 WHERE yourWhereClause

答案 1 :(得分:1)

您无需更改列名称。您可以更新

UPDATE process.dbo.vw_NewHireProcess 
SET OwnerId = 'New Value whatever you want'  WHERE OwnerId = 'Current Value'

答案 2 :(得分:1)

像这样:

select clientLastName__c, 
  clientFirstName__c, 
  clientID__c, 
  Category_ID__c, 
  ID AS Incident__c, 
  '95939439uuxx' AS OwnerId, 
  SystemTypeDesc as taskDescription__c 
from process.dbo.vw_NewHireProcess 
Where System_Type__c IS NOT NULL
祝你好运!

答案 3 :(得分:0)

如果您只想将常量值作为ownerid列返回,则可以执行以下操作:

select clientLastName__c, 
       clientFirstName__c, 
       clientID__c, 
       Category_ID__c, 
       ID AS Incident__c, 
       42 as OwnerId, 
       SystemTypeDesc as taskDescription__c 
from process.dbo.vw_NewHireProcess 
Where System_Type__c IS NOT NULL

如果要根据该列中的值为ownerId返回不同的值,可以执行以下操作:

select clientLastName__c, 
       clientFirstName__c, 
       clientID__c, 
       Category_ID__c, 
       ID AS Incident__c, 
       case 
         when OwnerId < 100 then -1
         when OwnerId >= 100 and ownerId < 1000 then 1
         else 42
       end as ownerId
       SystemTypeDesc as taskDescription__c 
from process.dbo.vw_NewHireProcess 
Where System_Type__c IS NOT NULL

但这些都不会改变数据库中存储的值。当您选择值时,它只是一个替代品。