SQLServer

How to do an update from a select with summarized registers in SQLServer

  • Star
  • Star
  • Star
  • Star
  • Star

Update from summarized registerA very powerful way to do a table's update in a SQL Server database is to link it with another table with a join, and updating the fields of everyone of its registers using the field's values of the registers linked with the another one. This technique had been discussed in the forum post Update with join or update from select in SQL Server..

Avoiding errors concatenating fields with numerical values in SQL Server

  • Star
  • Star
  • Star
  • Star
  • Star

concatenate stringsThe operator to concatenate in SQL Server is '+', but this operator is also used to add values.

 

Being the same operator for both, the query analyzer makes a concatenation or a sum based on the type of data fields being treated. If the fields are of 'string' type, the operator concatenate, and if it has numeric fields, two integers, for example, it add the two values.