SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Prioritised list to table

By Keith Henry,

I wrote this to allow me to send a priority list of int ids.

This takes a "," seperated list of integers and puts them into a table, along with an [insorder] field that allows you to sort them.

eg 2,6,3,1,7 becomes

ints insorder
---- --------
1    7
2    1
3    5
6    3
7    9

Depending on what sort of query plan you need you could move the primary key to the insorder field

Total article views: 66 | Views in the last 30 days: 1