title: Convert string to integer and update into other field
body: <p>I have a table that has the following structure</p>
  
  <pre><code>[zip] = &lt;zip, nvarchar(4),&gt;
  [cityZipID] = &lt;cityZipID, int,&gt;
  </code></pre>
  
  <p>In the <code>zip</code> column there is a string containing 4 digits and this is a number between 1000 an 1239 gut stored as a string.</p>
  
  <p>For some reason I need to calculate an other value out of this so I need to convert the string into an integer and store it into an other column called <code>cityZipID</code>. I want to do this using SQL Server Management Studio because it has to convert about 32000 lines so I cannot easily do it by hand. </p>
  
  <p>I tried the following but get only an error message when trying to execute it</p>
  
  <pre><code>UPDATE [MyTestData].[dbo].[Addresses]
     SET [cityZipID] = ((int)[zip])/10 -100
   WHERE [city] = 'Wien'
  </code></pre>
  
  <p>The column of <code>cityZipID</code> is null in the moment and should be filled with  numbers for the districts like the plzl for the first district is 1010 the 12th district is 1120  So the calculation would result in 1120 / 10 = 112 -100 = 12 and this would be the wanted result.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Jonny</p>