Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Conversion failed when converting the varchar value ' WHERE statusID = 1' to data type int. Expand / Collapse
Author
Message
Posted Thursday, September 26, 2013 7:16 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, October 21, 2013 3:10 AM
Points: 79, Visits: 191
Hi everyone

why is this statement has error??.. :-( i can't figure it out..

SET @statusID = ' AND statusID = ' + convert(varchar(20), @statusID)
Post #1499135
Posted Thursday, September 26, 2013 8:13 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 9:53 PM
Points: 3,438, Visits: 5,390
enriquezreyjoseph (9/26/2013)
Hi everyone

why is this statement has error??.. :-( i can't figure it out..

SET @statusID = ' AND statusID = ' + convert(varchar(20), @statusID)


Most likely, the declaration for @statusID looks like this:

DECLARE @statusID INT;





My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
Post #1499145
Posted Thursday, September 26, 2013 8:20 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, October 21, 2013 3:10 AM
Points: 79, Visits: 191
dwain.c (9/26/2013)
enriquezreyjoseph (9/26/2013)
Hi everyone

why is this statement has error??.. :-( i can't figure it out..

SET @statusID = ' AND statusID = ' + convert(varchar(20), @statusID)


Most likely, the declaration for @statusID looks like this:

DECLARE @statusID INT;




HAHAHAHA..thanks dwain wade
Post #1499148
Posted Friday, September 27, 2013 1:58 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 1:14 PM
Points: 40,615, Visits: 37,081
More insecure dynamic SQL....

Please, do you company a favour and stop writing dynamic SQL until you've read up and understand SQL injection.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1499240
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse