An example of inconsistent resolution of metadata

Source: Internet
Author: User
Tags filter end join sql ole query
Resolution | Data stored procedures are as follows:
ALTER procedure D_sel_bj_xcl
@filter varchar, @sortstr varchar, @iskw bit
As
Set @sortstr = ' Spzyflid,spkw,spid '
DECLARE @sql varchar (8000)
Set @sql = '
Select Spid,ckid,spmc,spgg,czmc,bzmc,cdmc,zlmc,spjldw,spkw, '
If @iskw =1
Set @sql = @sql + ' kwh, '
Set @sql = @sql + '
SUM (case when a.crklbfx=1 then SL ELSE-SL end) as Spxcl from (
Select A.*,b.spzyflid,b.spmc,b.spgg,cz.czmc,bz.bzmc,cd.cdmc,zl.zlmc,b.spjldw,
Spkw=case when Patindex ('% ([0-9][0-9][0-9][0-9]) ', B.SPMC) >0
Then right (spmc,6) Else "" End,
C.CRKLBFX from BJLSB A
Join CRKLB C on a.crlb=c.crklbid
Left join SP B on a.spid=b.spid
Left join CZ on B.spczid=cz.czid
Left join BZ on B.spbzid=bz.bzid
Left join ZL on B.spzlid=zl.zlid
Left JOIN CD on B.spcdid=cd.cdid
Where a.iszf is null '
If Len (@filter) >0
Set @sql = @sql + ' and ' + @filter
Set @sql = @sql + ') a
GROUP BY Spid,spzyflid,ckid,spmc,spgg,czmc,bzmc,cdmc,zlmc,spjldw,spkw '
If @iskw =1
Set @sql = @sql + ', kwh '
If Len (@sortstr) >0
Set @sql = @sql + ' ORDER BY ' + @sortstr
EXEC (@sql)


The procedure for the call is as follows:
SELECT * FROM
OPENROWSET (' SQLOLEDB ',
' Jszg '; ' Sa '; ' 6162900 ',
' Execute zgerp. D_sel_bj_xcl ' ckid= ' ', ' ', ' ', ', ', 0 ' as a

The results are:
Server: Message 7355, Level 16, State 1, line 1
OLE DB Provider ' SQLOLEDB ' provides inconsistent metadata for the column. The name was changed while executing.
OLE DB error tracking [non-interface error:ole DB provider returned different names for a column:providername= ' SQLOLEDB ', Compilet Imecolumnname= ' kwh ', runtimecolumnname= ' spxcl ', Rowset=execute zgerp. D_sel_bj_xcl ' ckid= ' 45 ', ', ', 0].

Take a closer look and you can see that the kwh column exists, and if you use location management, then, the location number is a summary of the basis, but the query is set to 0, which is different from the compiled columns, compiled to produce all the columns, so there is this error, really think of no good way, will query when 0 set to 1, Anyway, do not use the location to manage, the resulting number is not affected:)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.