0
我有列AccountNo
(varchar(50)
)。當我嘗試使用AccountNo
作爲過濾器來搜索數據,然後我得到一個錯誤味精如下在SQL Server 2005中將varchar轉換爲數據類型int時出錯
我dataTable的結構如下:
和我的代碼,這給了我錯誤是
SELECT
Date, particular,
flag_voucherType +' '+ CONVERT(VARCHAR,C.billNo) AS [VoucherNo.],
Debit, Credit, Narration
FROM
((SELECT
Particular, flag_voucherType,accountNo,companyId
FROM
tblInsertParticularRecord
WHERE
Credit = 0
AND flag = CONVERT(VARCHAR(50), @accountNum)
AND companyId = @companyId) AS A
INNER JOIN
(SELECT
CONVERT(Decimal,0) AS Debit, Debit AS Credit, accountNo,companyId, billNo
FROM tblInsertParticularRecord
WHERE
flag1 = 0
AND flag = CONVERT(VARCHAR(50), @accountNum)
AND companyId = @companyId) AS B ON A.accountNo = B.accountNo AND A.companyId = B.companyId)
INNER JOIN
(SELECT
Date, billNo, companyId, Narration
FROM tblJournalDateNarrationDetails) AS C ON (B.billNo = C.billNo AND B.CompanyId = C.companyId)
哪些值有@companyId?必須是整數。和@accountNum? – user3401335
看來你還有一個表作爲tblJournalDateNarrationDetails,請分享該表的架構。 – AK47
[踢壞的習慣:選擇錯誤的數據類型](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/12/bad-habits-to-kick-using-the-wrong-data- type.aspx) - 你應該總是使用最合適的數據類型 - 畢竟這就是他們所在的地方! –