473,508 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sql Server datatype values issue

2 New Member
Hi,

I have come across a strange scenario while executing a query. I was surprised by the way Sql Server was executing the query.

Quote:
Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 10 MR.MerchantContactFirstName + ' ' + MR.MerchantContactLastName AS MerchantName, 
  2. AISLTrans.DeviceID,AISLTrans.TransactionID, AISLTrans.CardNumber, AISLTrans.TransactionDateTime, 
  3. AISLTrans.TransactionStatus, AISTRNSTYPE.TransactionType AS TransactionRequestType,AISLTrans.TransactionAmount,
  4. (AISLTrans.BasePointEarn+AISLTrans.BonusPointEarn)AS 'Point Awarded'
  5. FROM AISLoyaltyTransactions AISLTrans INNER JOIN 
  6. MerchantRegistration MR 
  7. ON AISLTrans.MerchantID = MR.MerchantID INNER JOIN 
  8. AISTransactionTypes AISTRNSTYPE 
  9. ON AISLTrans.ProcessingCode = AISTRNSTYPE.ProcessingCode AND 
  10. AISLTrans.TransactionType = AISTRNSTYPE.MessageType WHERE AISLTrans.TransactionType = 0200 
  11. AND AISLTrans.ProcessingCode = 071000 ORDER BY AISLTrans.TransactionDateTime DESC

In above query the field ISLTrans,TransactionType works fine for all the values except 0200 it accepts all interger values though the field type is of varchar.

But when I give the value as 0200 it throws exception saying cannot convert varchar to int.

I am looking for why the query is still executing though I am providing integer value instead of varchar and if it is executing why its not accepting all the integer values which I provide.

Thanks,
Praveen Nelge
Jul 17 '14 #1
1 1241
Rabbit
12,516 Recognized Expert Moderator MVP
SQL Server will try to implicitly convert data types to match. You should not rely on this in your queries. You should explicitly make sure that the data types match, otherwise you can run into issues as you are now.

Failure to convert the data type from char to int can come about a few different ways. It could be an overflow issue, or an invalid character issue, or a decimal, etc. There's no way to know without looking at the actual data it is trying to convert.
Jul 17 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2440
by: Miranda johnsen | last post by:
Hello, I need some help with passing a value from my login authorization page. The authorization is done with the code below (it works), but I need the 'uName' value passed on when the...
3
1836
by: | last post by:
Hi, When I create a table in MS access 2000 with SR3 using a standard SQL Create command The BOOL (YesNo) columns are NOT checkboxes, they are ints. When I create a table using the designer...
1
3266
by: Programmer | last post by:
Hi All Here is my problem I'm using a SQLDataAdapter and DataSet I use the method FillSchema(myDataset, SchemaType.Source) The problem is that when i Check the default Values of the Dataset...
1
2406
by: Teddy | last post by:
Language: C Excel Reading Method: ExecuteReade I am currently running into a challenge reading excel data when datatype formats are different in the SAME column. It seems like datatype (in the...
2
2143
by: Mark Rae | last post by:
Hi, Can anyone please point me to a definitive mapping of SQL Server 2000 datatypes to C# datatypes? I'm currently using the mapping below, but I'm sure some aren't correct... BigInt, int...
2
2071
by: Steve Franks | last post by:
In ASP.NET 2.0 you can now apparently do this: <asp:label runat="server" text="some browser" IE:text="any IE browser" IE5:text="the IE 5 browser" PIE:text="the Pocket PC browser" /> Now the...
0
2204
by: Charles Leonard | last post by:
I am having yet another issue with Windows Server 2003. This time, the web service (a file import web service) appears to run except for one odd message: "ActiveX component can't create object". ...
0
1394
by: abdellatif | last post by:
hi all i have installed a 2 nodes cluster (active/passive)win2003 sp1 containing an exchange2003 virtual server and sqlserver2000(sp3) virtual server. everything work well, after 1 month the...
5
4183
by: tjaink | last post by:
Hi I have a vc++ dll and its stored in Windows directory. I am using OS Windows 2003 server. And i am using ASP Legacy application migrated from NT to Windows 2003 server. Now there is no problem...
3
1342
by: Rohit | last post by:
I am using SQL Server Express Edition with ASP.NET. I want to know which data type to use for storing large articles.
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.