存储过程出错 [英] Error in Stored Procedure

查看:150
本文介绍了存储过程出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的存储过程,

My Stored Procedure,

alter procedure usp_temp_tutor_details
(
	@page		int,
	@pagesize	int
)
as
begin

create table #temp_tutor_details
(	
	id				int		IDENTITY(1,1),
	FacultyId		int,
	FacultyName		varchar(50),
	FacultyAddress	varchar(250),
	FacultyCity		varchar(50),
	FacultyMobile	varchar(30),
	FacultyExp		varchar(300)
)
	
		set identity_insert #temp_tutor_details on
				
			insert into #temp_tutor_details(FacultyId, FacultyName, FacultyAddress, FacultyCity, FacultyMobile, FacultyExp)
			
			select distinct tlm.Std_Fac_Id as FacultyId,
			ttm.Fname as FacultyName, ttm.Faddress as FacultyAddress, ttm.Fcity as FacultyCity, ttm.Fmobile as FacultyMobile, 
			ttm.Fexp as FacultyExp
			from tbl_loginMaster3 tlm full join tbl_tutorMastering ttm on
			ttm.FacultyId = tlm.Std_Fac_Id where tlm.Role = 'faculty'
			
		set	identity_insert #temp_tutor_details on	
		
		declare @from int
		declare	@to	  int
		set		@to		=	@page - @pagesize
		set		@from	=	@page * @pagesize - @pagesize
	
		select * from #temp_tutor_details where id > @from and id < = @to
		select COUNT(*) from #temp_tutor_details
		drop table #temp_tutor_details
		
end





错误:



Error:

Msg 545, Level 16, State 1, Procedure usp_temp_tutor_details, Line 22
Explicit value must be specified for identity column in table '#temp_tutor_details_________________________________________________________________________________________________000000000025' either when IDENTITY_INSERT is set to ON or when a replication user is inserting into a NOT FOR REPLICATION identity column.

(0 row(s) affected)

(1 row(s) affected)

推荐答案

删除以下行:



Remove these lines:

set identity_insert #temp_tutor_details on

上设置identity_insert #temp_tutor_details


set         @from    =    ((@page-1) * @pagesize)+1
    set         @to        =    @from+(@pagesize-1)


这篇关于存储过程出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆