SQl server 2005中的查询问题 [英] Query Problem in SQl server 2005
本文介绍了SQl server 2005中的查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个查询,我无法找出错误。
Hi,
I have a query where i am not been able to find out errors.
SELECT
dbo.SalePurchase.tran_date AS billdate
,LEFT(dbo.SalePurchase.tran_no, 1) + RIGHT(dbo.SalePurchase.tran_no, 8) AS BILLNO
,dbo.GL.AcName, Item_1.ItemName
,dbo.IT.iRate
,dbo.IT.iAmount AS amt
,Item_1.UOM
,dbo.IT.iQty
,dbo.SalePurchase.sp_dr
,AddressBook_1.FullName
,dbo.SalePurchase.sp_cr AS bamt
,GenMast_1.GenName AS itemgroup
,dbo.Item.ItemName AS subitem
,dbo.AddressBook.FullName AS tagidar
,GenMast_2.GenName AS city
,dbo.GenMast.GenName AS district
,salepurchase.sp_cr-salepurchase.sp_basic as tamt
FROM
dbo.AddressBook
RIGHT OUTER JOIN dbo.GenMast AS GenMast_2
INNER JOIN dbo.GenMast ON GenMast_2.GroupCd = dbo.GenMast.Code
RIGHT OUTER JOIN dbo.GL ON GenMast_2.Code = dbo.GL.CityCd ON dbo.AddressBook.Code = dbo.GL.TagadgirCd
RIGHT OUTER JOIN dbo.SalePurchase ON dbo.GL.AcCode = dbo.SalePurchase.ac_code
LEFT OUTER JOIN dbo.AddressBook AS AddressBook_1 ON dbo.GL.BrokerCd = AddressBook_1.Code
LEFT OUTER JOIN dbo.Item
RIGHT OUTER JOIN dbo.IT ON dbo.Item.Code = dbo.IT.SubItemCd ON dbo.SalePurchase.Code = dbo.IT.SPCode
LEFT OUTER JOIN dbo.Item AS Item_1
LEFT OUTER JOIN dbo.GenMast AS GenMast_1 ON Item_1.GroupCd = GenMast_1.Code ON dbo.IT.ItemCode = Item_1.Code
WHERE (salepurchase.sp_type='sr')
ORDER BY LEFT(dbo.SalePurchase.tran_no, 1) + RIGHT(dbo.SalePurchase.tran_no, 8)
n执行显示 无法将char转换为datetime
。虽然 trandate
的数据类型设置为 DateTime
。错误仍然存在。
请帮助..
n execution showing "unable to convert char to datetime
". Although the data type for trandate
is set to DateTime
. The error remains.
Please help..
推荐答案
尝试在这里查找地点或贴纸使用日期列的地方,无法识别dbo.SalePurchase.sp_dr这是什么?如果在此用户定义的函数中使用了日期,那么请计算出来。问题是你试图使用日期列作为字符串/文本,或者将它与错误的实体进行比较或者使用错误的函数。
Try to find the place or paster here all places where dates column is used , unable to identify dbo.SalePurchase.sp_dr what is this ? if date is used in this user defined function then figure it out. The problem is you are trying to use date column as string/text either comparing it with wrong entity or using wrong function over it.
这篇关于SQl server 2005中的查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文