English 中文(简体)
Ambiguous Sql Error From VS-2005
原标题:Ambiguous Sql Error From VS-2005

这是一个严重的问题:它是否在Sql Query Analyzer?

我面临奇怪的情况,我在Sql Query Analyzer的问询中做了测试:

insert into PLCommonTotal(CmnTotal)
select
case
when p.NetpurTot > s.NetsalTot then
(
select NetpurTot from PLPurchaseTotal
)
else
(
Select NetsalTot from PLSaleTotal
)
end
from PLPurchaseTotal p
join PLSaleTotal s
on p.companyID=s.companyID

select * from PLCommonTotal

该公司从Sql Query Analyzer处工作,没有错误。

如今,在2005年5月5日调查了同样的问题:

string tot5 = " insert into PLCommonTotal(CmnTotal)" +
                " select" +
                " case" +
                " when p.NetpurTot > s.NetsalTot then" +
                " (" +
                " select NetpurTot from PLPurchaseTotal" +
                " )" +
                " else" +
                " (" +
                " Select NetsalTot from PLSaleTotal" +
                " )" +
                " end" +
                " from PLPurchaseTotal p" +
                " join PLSaleTotal s" +
                " on p.companyID=s.companyID";
            SqlCommand comcmd = new SqlCommand(tot5, con);
            comcmd.Transaction = trans;
            comcmd.ExecuteNonQuery();

This is throw Sql Error : “ subquery return more than one value. This is not permitted when the subquery follows = != < <= > >= or when the subquery used an expression. The statement has been termited”.

I want to ask the question if it is not permitted than why it is executed from SQL Query analyzer without any error?.

Is there fault of SQL Team?.

最佳回答

如你写了询问,如果你在编码>上有超过一行,则会出现这种情况。 我认为,在SSMS和VS-2005年期间,你没有使用同一行。

另一方面,我怀疑,这是你想要的。

insert into PLCommonTotal(CmnTotal)
select
  case
    when p.NetpurTot > s.NetsalTot
    then p.NetpurTot
    else s.NetsalTot
  end
from PLPurchaseTotal p
  join PLSaleTotal s
    on p.companyID=s.companyID
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签