2

Bowzerという列を持つ というテーブルがありますType

このクエリを実行しようとすると、SSMS は列を認識しませんType

これが私のクエリです

update Bowzer
set inserted_by = ISNULL(inserted_by, 'Auto')
where (bowzer_id = 8 and inserted_by is null and type='CRUDE')

ここでは、列が認識されずType、エラーが発生します

列名のタイプが無効です

この列名は許可されてTypeいませんか?

また、Inserted_By列がnullかどうかを確認してから値に置き換えたいAuto

それ、どうやったら出来るの?

編集 - テーブルバウザーへの 1 DDL

CREATE TABLE [dbo].[Bowzer](
    [bowzer_id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
    [bowzer_no] [nvarchar](20) NULL,
    [quantity] [numeric](18, 0) NULL,
    [dip1] [numeric](18, 0) NULL,
    [Cmpt_Capacity1] [numeric](5, 0) NULL,
    [dip2] [numeric](18, 0) NULL,
    [Cmpt_Capacity2] [numeric](5, 0) NULL,
    [dip3] [numeric](18, 0) NULL,
    [Cmpt_Capacity3] [numeric](5, 0) NULL,
    [dip4] [numeric](18, 0) NULL,
    [Cmpt_Capacity4] [numeric](5, 0) NULL,
    [dip5] [numeric](18, 0) NULL,
    [Cmpt_Capacity5] [numeric](5, 0) NULL,
    [expiry_date] [datetime] NOT NULL,
    [status] [bit] NOT NULL,
    [inserted_on] [datetime] NULL,
    [inserted_by] [nvarchar](20) NULL,
    [Type] [nvarchar](50) NULL,
 CONSTRAINT [PK_Bowzer] PRIMARY KEY CLUSTERED 
(
    [bowzer_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
4

2 に答える 2

4

これを試して

update Bowzer
set inserted_by = ISNULL(inserted_by, 'Auto')
where (bowzer_id = 8 and inserted_by is null and [type]='CRUDE')
于 2012-06-14T05:07:40.010 に答える
1

null かどうかを確認するには、Case を使用します

Update Bowzer set inserted_by  = Case When inserted_by IS NULL THEN 'Auto' Else inserted_by End
where (bowzer_id = 8 and inserted_by is null and [type]='CRUDE')
于 2012-06-14T05:11:30.887 に答える