<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar/8776281485402821239?origin\x3dhttp://mythoughtsaboutcode.blogspot.com', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

.

Selecting Random Row from a SQL SELECT Statement
Friday, March 23, 2007

Well I just found something cool as I was looking for a way to select some data from a SQL Server table and only return 1 random row. Pretty easy too:

SELECT TOP 1 columnName FROM table ORDER BY NEWID()

Works like a charm.

Labels: , ,



Digg!

Read This

All entries in this blog are my opinion and don't necessarily reflect the opinion or views of my employer (Terralever).

This is where I talk about the little bit of .NET code that I actually know and different techy things that interest me. Feel free to tell all your friends about my little blog and hopefully soon, it won't be so little.

My Thoughts About Code | feed

5ThirtyOne and Blogger Templates design | Top