Code
CREATE TABLE [dbo].[HR_OnOffDutyLog](
[ID] [bigint] NOT NULL,
[DutyID] [bigint] NOT NULL,
[MonthDutyTableName] [varchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
[EmployeeID] [bigint] NOT NULL,
[STATUS] [smallint] NOT NULL,
[CheckInTime] [datetime] NOT NULL,
CONSTRAINT [PK_HR_OnOffDutyLog] 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]
CREATE TABLE [dbo].[HR_OnOffDuty_200906](
[DutyID] [bigint] NOT NULL,
[DutyTime] [datetime] NOT NULL,
[EmployeeID] [bigint] NOT NULL,
CONSTRAINT [PK_HR_OnOffDuty_200906] PRIMARY KEY CLUSTERED
(
[DutyID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
现在要读取HR_OnOffDutyLog 里的数据,并且根据DutyID 和MonthDutyTableName 读取DutyTime,显示出来
HR_OnOffDuty_200906 是月分表
动态SQL怎么写? 就是卡在动态读取月份表里的数据了