Sql tips

A few tips useful for your Sql Query…

Update with a join:

 UPDATE MyTable 
  SET Column = NewValue 
  FROM MyTable  INNER JOIN OtherTable ON MyTable.Key = OtherTable.Key 

trimming…
  select LTRIM(RTRIM(columnOne)) from table1 

select into
 
 SELECT Persons.LastName,Orders.OrderNo 
  INTO Backup 
  FROM Persons 
  INNER JOIN Orders  ON Persons.P_Id=Orders.P_Id

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s