Why does the sql select statement fail? -


In the scenario below, the final selection fails from the alliance view, why any thoughts?

The subset table does not contain a single line that corresponds to one in the mastercod, which is not assigned any integer values.

  Create Table MasterCode (ID INT, code VARCHAR (10)) Select Tab Subset (ID INT) Select SID, M. Combine code, CAST (M.Code ANNT), Intradode with substrate s inner MAID = S IDCET MasterCard (ID, code) values ​​(ID, code) values ​​on MasterCard M (1, '1') INSERT MasterCard (ID, code) value (2, '2') MasterCard (ID, code) value (3, 'three') INSERT MasterCoodes ID, code) value (4, '4') INSERT subset (id) values ​​(1 ) INSERT subset (id) values ​​(2) select INSERT subset (id) values ​​(4) * from the combination - Selects 3 rows * Adds WHERE code = '2' - 1 row returned SELECT * to WHERE code = '3' - 0 rows mixed SELECT * FROM Combine WHERE IntCode = 2 - Failure, error Msg msg 24, Level 16, state is 1, failed to convert line 15 conversion varchar values ​​into 'three' data type int.  

Environment is on Sql2k5 standard (64-bit) Win2k3 server R2

Maybe in some lines, M. The code literally means "three", and the scene is trying to put a non-numerical looking word into an integer (you can probably put "3" in an int, but not "puppy" or "Three", etc.).

EDIT: A comment was added, but here's the appropriate to add it. SQL Server is going to try and execute and possibly be involved efficiently, and it is going to try and wherever applicable explicitly the section applies.

If you believe that VIEWs work almost nowadays, a real table has to do something similar for it; Otherwise, it will be included in everything and will return all prices before being filtered.

Extremely expensive.

I am not sure whether the execution plan will show the expansion of this level.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -