If you want to show a 1 when there is a value for something in the column and 0 if none of the rows have that values you typically do something like this CASE WHEN SUM(CONVERT(INT,SomeValue)) > 0 THEN 1 ELSE 0 END Basically you sum it up and if the sum is greater than 0 then you show 1 otherwise you show 0 Here is what it might look like in code First create the following table with this data
This is an archive of the posts published to LessThanDot from 2008 to 2018, over a decade of useful content. While we're no longer adding new content, we still receive a lot of visitors and wanted to make sure the content didn't disappear forever.
Recently, I was having to test an application to which I had made some modifications to fix an error that had been discovered. In the course of testing the changes I had done, I found myself with an error that was disturbingly familiar. The application was an ASP app and the error was a server.createobject error indicating that the object could not be created. I have come across this error at least a few times previously but it had been a while. As I normally do when I find myself in a situation that needs a resolution, I went to Google (though I will have to start using Bing to see how well it performs – much as SQLDenis has noted in one of his recent blog entries). My search results came back rather unsatisfyingly with answers that I had already looked at and confirmed were not really issues. I checked again by running through the tests and it was still failing at the point of creating the object.
If you use the FOR XML syntax in SQL Server it can be a little tricky to get the XML formatted the way you really want it. For every table that you have in a join it becomes a child of the table before. What if you have a 3 table join and you want one table to be the parent and the two tables that you are joining to be on the same level, I will show you how you can accomplish that.
If you are upgrading from windows xp to windows 7 there is a change in the way you install Internet Information Services. On windows xp you would install IIS from add/remove windows components. This is different in Windows 7; it is very similar how it is done on Vista. Go to Control Panel and click on Programs, on the following screen click on Turn Windows features on or off (see image below)
Recently I had to do some data manipulation against a Sybase linked server running on a Unix box. When you have a linked server you can use OPENQUERY do perform DML statements like delete, update and inserts but the syntax is a little different So let’s look at some code, first create a linked server on your machine that is linked to your machine. You can add a linked server through the wizard or through the sp_addlinkedserver stored proc
This question was asked yesterday in our forums A transport-level error has occurred when sending the….. by Impal3r When i have a query window open In SSMS and I step away for a while and then I run the query I get the following error A transport-level error has occurred when sending the request to the server what I do then is disconnect from the server, connect again and then I can open anew query window to run the query again. This seems tedious and not really productive. Is there a better way to get around this?
If you have a bunch of User-Defined Data Types in your databases and you would like to get a list of them then you can run the following query On SQL Server 2000 and up select * from systypes where xusertype > 256 or On SQL Server 2005 and up SELECT * FROM sys.Types WHERE is_user_defined = 1 Let’s take a look how this works by adding a couple of User-Defined Data Types. we will add a birthday type which will be a datetime (on SQL Server 2008 it should be a date) and a StateCode which is a char(2)
I will just start of by saying that Beginning Spatial With SQL Server 2008 written by Alastair Aitchison is a truly awesome book. Although I have tinkered a little with the new geospatial capabilities in the SQL Server 2008 Proximity Search With The Geography Data Type blog post I did not really understand or know that there were so many nuances and things that you had to be careful about. Did you know that there are different map projections? This book will show you the differences between the Hammer-Aitoff map projection, the Mercator map projection and the equirectangular map projection. You will also learn what the different spatial reference systems that SQL server 2008 supports are.
Bing is the latest version of a search engine developed by Microsoft. Microsoft was developing and testing for the last couple of months a search engine with the name Kumo which in Japanese means spider or cloud. Kumo was of course just the code name for what would become eventually Bing. Search is very important because 1% of the search market is roughly worth 1 billion dollars. This means that the number two player can make some decent money. Microsoft doesn’t have to become number one but they need to just grab around 30% or so and they are in good shape. Since Bing was launched it actually surpassed Yahoo and took market share away from both Google and Yahoo. Google must be eyeing this with great interest because a couple of weeks ago the WolframAlpha decision engine was launched and now Bing is here. Did you see the pathetic answer from Google to WolframAlpha named Google Squared
Every time you buy a new computer you of course need to install a bunch of software. In my case this would be stuff mostly from MSDN _Visual Studio 2008 + Service pack 1 SQL Server 2008 + Service pack 1 Expression Studio 2 Win XP SP 3 (to run on a virtual machine) Windows 7 RC (to run on a virtual machine) Visual Studio 2010 (to run inside the Win 7 virtual machine)