关于sqlserver2008r2如何将表中的某个字段的值替换成表中的另一个字段的值

有表Function功能表:

CREATE TABLE PlatformFunction(
    [id] [bigint] IDENTITY(1,1) NOT NULL,
    [parent_id] [bigint] NULL,
    [function_name] [nvarchar](20) NULL,
    [function_type] [nvarchar](20) NULL,
    [function_url] [nvarchar](200) NULL,
    [function_icon] [nvarchar](200) NULL,
    [function_order_id] [int] NULL,
    [function_create_time] [datetime] NULL,
    [function_status] [int] NULL,
 CONSTRAINT [PK_PLATFORMFUNCTION] PRIMARY KEY CLUSTERED 
(
    [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

表中的数据有:

SET IDENTITY_INSERT PlatformFunction ON
INSERT PlatformFunction ([id], [parent_id], [function_name], [function_type], [function_url], [function_icon], [function_order_id], [function_create_time], [function_status]) VALUES (1, 82, N'管理人员管理', N'1', N'/admin/role/index', NULL, 1, CAST(0x0000A99E00000000 AS DateTime), 1)
INSERT [dbo].[PlatformFunction] ([id], [parent_id], [function_name], [function_type], [function_url], [function_icon], [function_order_id], [function_create_time], [function_status]) VALUES (2, 1, N'管理人员列表', N'1', N'/admin/role/operator_list', NULL, 1, CAST(0x0000A99E00000000 AS DateTime), 1)
INSERT [dbo].[PlatformFunction] ([id], [parent_id], [function_name], [function_type], [function_url], [function_icon], [function_order_id], [function_create_time], [function_status]) VALUES (3, 1, N'角色列表', N'1', N'/admin/role/role_list', NULL, 1, CAST(0x0000A99E00000000 AS DateTime), 1)

现在需要将function_order_id字段的值改为id的SQL是:

update PlatformFunction set function_order_id =id


 

你可能感兴趣的:(sql)