I need to update a table with values passed as parameters from a desktop application. But every time I try to run the query I just get this error :

> 
> Msg 245, Level 16, State 1, Line 5
>  Conversion failed when converting the varchar value 'UPDATE
>  table
>  SET 
>  TypeId = ' to data type int.
> 
> 
> 

I tried to isolate the problem by reducing the code to a minimum, and below is the shortest snippet of my actual code and still the problem occurs. I figure its most likely a syntax problem, but after browsing similar issues for a while now, I still can't seem to figure out the problem.

```
DECLARE @typeId int = 175;
DECLARE @item varchar(20)= 'ABC123'
DECLARE @SQLScript varchar(5000);

SET @SQLScript =   'UPDATE
                        table
                    SET 
                        TypeId = ' + @typeId + '
                    WHERE item = ''' + @item + '''
                   '
Print(@SQLScript);

```

What I would expect to come out as a result from the `Print(@SQLScript)` is
the query: 

```
UPDATE
    table
SET
    TypeId = 175
WHERE
    item = 'ABC123'

```