CREATE PROCEDURE [dbo].[OLTR_ExamSelectCountThree]
(
@StudentID varchar(10),
@CourseID varchar(10)
)
AS DECLARE @tn varchar(100),
@sql varchar(4000),
@yy nvarchar(30)
set @yy=getdate()
set @yy=Year(@yy)
set @yy=substring(@yy,3,2)
set @tn='OLTR_ExamStudentExamRecard'+@yy set @sql=
'select Count(ScoreNum1) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+''''
'select Count(ScoreNum2) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+'''' 'select Count(ScoreNum3) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+''''
GO
(
@StudentID varchar(10),
@CourseID varchar(10)
)
AS DECLARE @tn varchar(100),
@sql varchar(4000),
@yy nvarchar(30)
set @yy=getdate()
set @yy=Year(@yy)
set @yy=substring(@yy,3,2)
set @tn='OLTR_ExamStudentExamRecard'+@yy set @sql=
'select Count(ScoreNum1) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+''''
'select Count(ScoreNum2) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+'''' 'select Count(ScoreNum3) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+''''
GO
(
@StudentID varchar(10),
@CourseID varchar(10)
)
AS DECLARE @tn varchar(100),
@sql varchar(4000),
@yy nvarchar(30)
set @yy=getdate()
set @yy=Year(@yy)
set @yy=substring(@yy,3,2)
set @tn='OLTR_ExamStudentExamRecard'+@yy set @sql=
'select Count(ScoreNum1) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+'''' +
'select Count(ScoreNum2) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+'''' +
'select Count(ScoreNum3) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+''''
GO
不然怎么执行...
CREATE PROCEDURE [dbo].[OLTR_ExamSelectCountThree]
(
@StudentID varchar(10),
@CourseID varchar(10)
)
AS DECLARE @tn varchar(100),
@sql varchar(4000),
@yy nvarchar(30)
set @yy=getdate()
set @yy=Year(@yy)
set @yy=substring(@yy,3,2)
set @tn='OLTR_ExamStudentExamRecard'+@yy set @sql=
'select Count(ScoreNum1) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+'''' +' '+
'select Count(ScoreNum2) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+'''' +' '+
'select Count(ScoreNum3) from '+@tn+' where StudentID='''+@StudentID+''' and CourseID='''+@CourseID+''''
exec(@sql)
GO