Mar 13, 2014

Easy to use - for in clause - SQLServer

Many times I have to use, where in - and in the in clause list of comma separated column values from other table.

I use regular expressions to do the same, but always forget what to do.

Making a note of it for easy reference.

  1. Copy paste the selected column values in SQL Server Query editor.
  2. Ctrl + H - Search and replace.
  3.  Find what - "\n"
  4. Replace with -  ','
  5. Look in - "Current Document"
  6. Use - "Regular Expressions"
  7. You still need to put a ' for first and last value in the in clause. But that is easy to do manually. 

No comments: