wendang表
BH   typebh     FileName    IsPublic   username    zsname   uploadDate     filepath   demo  temp1 temp2 temp3 
wendang_type表
BH   Name   temp1  temp2  temp3wendang表中的typebh是wendang_type中的bh
想两表连接起来 取得wendang_type表的name
select  w.[BH],w.[typebh],w.[FileName],w.[IsPublic],w.[username],w.[zsname],w.[uploadDate],w.[FilePath],w.[Demo],w.[temp1],w.[temp2],w.[temp3],w.[temp4],w.[temp5] , wt.name typename FROM wendang w inner join  wendang_type wt on wt.bh=w.typebh
存储过程如下
CREATE PROCEDURE wdtest_GetRecordByPage
    @tblName      varchar(255),       -- 表名
    @fldName      varchar(255),       -- 字段名
    @PageSize     int = 10,           -- 页尺寸
    @PageIndex    int = 1,            -- 页码
    @IsReCount    bit = 0,            -- 返回记录总数, 非 0 值则返回
    @OrderType    bit = 0,            -- 设置排序类型, 非 0 值则降序
    @strWhere     varchar(1000) = ''  -- 查询条件 (注意: 不要加 where)
ASdeclare @strSQL   varchar(6000)       -- 主语句
declare @strTmp   varchar(100)        -- 临时变量
declare @strOrder varchar(400)        -- 排序类型if @OrderType != 0
begin
    set @strTmp = '<(select min'
    set @strOrder = ' order by [' + @fldName +'] desc'
end
else
begin
    set @strTmp = '>(select max'
    set @strOrder = ' order by [' + @fldName +'] asc'  --  >(select max
endset @strSQL = 'select top ' + str(@PageSize) + '  
                                                                        w.[BH], 
w.[typebh], 
w.[FileName], 
w.[IsPublic],
w.[username], 
w.[zsname], 
w.[uploadDate], 
w.[FilePath], 
w.[Demo], 
w.[temp1], 
w.[temp2], 
w.[temp3], 
w.[temp4], 
w.[temp5], 
[wt].[name]  typename
 FROM [' + @tblName + '] w  inner join  wendang_type wt 
on wt.bh=w.typebh 
 where [' + @fldName + ']' + @strTmp + '(['
    + @fldName + ']) from (select top ' + str((@PageIndex-1)*@PageSize) + ' ['
    + @fldName + '] from [' + @tblName + '] w ' + @strOrder + ') as tblTmp)'
    + @strOrderif @strWhere != ''
    set @strSQL = 'select top ' + str(@PageSize) + '                    w.[BH], 
w.[typebh], 
w.[FileName], 
w.[IsPublic],
w.[username], 
w.[zsname], 
w.[uploadDate], 
w.[FilePath], 
w.[Demo], 
w.[temp1], 
w.[temp2], 
w.[temp3], 
w.[temp4], 
w.[temp5], 
[wt].[name]  typename
 FROM [' + @tblName + '] w  inner join  wendang_type wt 
on wt.bh=w.typebh   where [' + @fldName + ']' + @strTmp + '(['
        + @fldName + ']) from (select top ' + str((@PageIndex-1)*@PageSize) + ' ['
        + @fldName + '] from [' + @tblName + ']  w where ' + @strWhere + ' '
        + @strOrder + ') as tblTmp) and ' + @strWhere + ' ' + @strOrderif @PageIndex = 1
begin
    set @strTmp =''
    if @strWhere != ''
        set @strTmp = ' where ' + @strWhere    set @strSQL = 'select top ' + str(@PageSize) + '                                                                         w.[BH], 
w.[typebh], 
w.[FileName], 
w.[IsPublic],
w.[username], 
w.[zsname], 
w.[uploadDate], 
w.[FilePath], 
w.[Demo], 
w.[temp1], 
w.[temp2], 
w.[temp3], 
w.[temp4], 
w.[temp5], 
[wt].[name]  typename
 FROM [' + @tblName + '] w  inner join  wendang_type wt 
on wt.bh=w.typebh  ' + @strTmp + ' ' + @strOrder
endif @IsReCount != 0
    set @strSQL = 'select count(*) as Total from [' + @tblName + '] w '+' where ' + @strWhereexec (@strSQL)GO执行的时候会出错,这个存储过程该怎么改,大家帮我看看