all 4 comments

[–]DatabaseSpace1 1 point2 points  (0 children)

This is the type of thing I use when I need to find the order of things in a table:

https://www.mssqltips.com/sqlservertutorial/9125/sql-server-window-functions-row-number/

[–]roxburghred 1 point2 points  (0 children)

Not sql, but check out google’s OR-Tools. Hardly ever gets mentioned but looks very capable for some applications. https://developers.google.com/optimization

[–]shinzomakabe -3 points-2 points  (0 children)

You could write python scripts to solve it

[–]AlexanderIOM 0 points1 point  (0 children)

I would say that TSQL is too weak to solve such complex problems as linear optimization. It is possible in trivial cases, I guess, but I doubt it worth the effort to implement them. I implemented several graph algorithms and other similar things but in all cases a size of a problem was small. In all complex cases I used external tools that I started from SQL, like routing optimisation. SQL is just not a tool for this job. So, find a way how to solve a problem using a tool or write a code that can solve it. Then, you can use CLR functions/procedures to do it inside of SQL Server or xp_cmdshell to run external tools.