具有1个声明值、2个update语句和1个insert语句的Sql存储过程
我在下面的存储过程中有这些错误 选择时,只能在选择列表中指定一个表达式 子查询不随EXISTS一起引入。列的名称或编号 提供的值与表定义不匹配具有1个声明值、2个update语句和1个insert语句的Sql存储过程,sql,sql-server,Sql,Sql Server,我在下面的存储过程中有这些错误 选择时,只能在选择列表中指定一个表达式 子查询不随EXISTS一起引入。列的名称或编号 提供的值与表定义不匹配 你在这里有什么问题?我有这些错误。当子查询未引入EXISTS时,只能在选择列表中指定一个表达式。提供的值的列名或数量与表定义不匹配。我无法运行此sql过程。您不能将*选择到单个变量中:Set@b_ComNo=select*from tbl_TeleCom,其中Type=@typetha谢。但我有一个错误! Create PROCEDURE [dbo].[
你在这里有什么问题?我有这些错误。当子查询未引入EXISTS时,只能在选择列表中指定一个表达式。提供的值的列名或数量与表定义不匹配。我无法运行此sql过程。您不能将*选择到单个变量中:Set@b_ComNo=select*from tbl_TeleCom,其中Type=@typetha谢。但我有一个错误!
Create PROCEDURE [dbo].[tbl_TeleCom_UpdateTeleComNo]
@type varchar(100) ,
@comNo varchar(100),
@status bit
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @b_ComNo varchar(100)
Set @b_ComNo = (Select * from tbl_TeleCom where Type = @type)
IF @b_ComNo IS NOT NULL
BEGIN
Insert Into tbl_ComNoHistory
Select B_ComNo, B_StartTime, B_EndTime
from tbl_TeleCom
where Type = @type
Group By B_ComNo, B_StartTime, B_EndTime
END
Update tbl_Balance Set
Status = 0
from tbl_Balance
Join tbl_TeleCom On tbl_TeleCom.CurrentComNo = tbl_Balance.ComNo
And tbl_TeleCom.Type = @type
Update tbl_TeleCom Set
CurrentComNo = @comNo,
CurrentTime = GETDATE(),
B_ComNo = CurrentComNo,
B_StartTime = CurrentTime,
B_EndTime = GETDATE()
where Type =@type
Update tbl_Balance Set
Status = @status
from tbl_Balance
Join tbl_TeleCom On tbl_TeleCom.CurrentComNo = tbl_Balance.ComNo
And tbl_TeleCom.Type = @type
END
Create PROCEDURE [dbo].[tbl_TeleCom_UpdateTeleComNo]
@type varchar(100) ,
@comNo varchar(100),
@status bit
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @b_ComNo varchar(100)
SELECT @b_ComNo = ComNo from tbl_TeleCom where Type = @type
IF @b_ComNo IS NOT NULL
BEGIN
Insert Into tbl_ComNoHistory
Select B_ComNo, B_StartTime, B_EndTime
from tbl_TeleCom
where Type = @type
Group By B_ComNo, B_StartTime, B_EndTime
END
Update tbl_Balance Set
Status = 0
from tbl_Balance
Join tbl_TeleCom On tbl_TeleCom.CurrentComNo = tbl_Balance.ComNo
And tbl_TeleCom.Type = @type
Update tbl_TeleCom Set
CurrentComNo = @comNo,
CurrentTime = GETDATE(),
B_ComNo = CurrentComNo,
B_StartTime = CurrentTime,
B_EndTime = GETDATE()
where Type =@type
Update tbl_Balance Set
Status = @status
from tbl_Balance
Join tbl_TeleCom On tbl_TeleCom.CurrentComNo = tbl_Balance.ComNo
And tbl_TeleCom.Type = @type
END