Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Compare int to nvarchar ?

$
0
0

Have a need to compare an nvarchar variable to an int value in a table.  
I thought I would have to cast nvarchar to int, but the direct compare seems to work.  Is this some sort of default conversion going on under the covers?

For example

DECLARE @itest AS INT

SET @itest = 4

DECLARE @vtest AS NVARCHAR(30)

SET @vtest = '4'

IF(@itest = @vtest)

BEGIN

PRINT 'it works'

END




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>