Category: SQL

Exec sp_help on a table with a schema

Really quick post regarding sp_help and tables in Schemas (not in dbo). Usually when doing a sp_help, you can do something resembling the following : However, if you try to do the same with a table with a Schema (SomeSchema.TableName) you will get an error “Incorrect syntax near ‘.’”. To execute the sp_help on a table with a schema, simply...

What’s the Difference Between Where and Having in SQL?

A really quick post for you all today over the differences between Where and Having in SQL. This has been a question in a lot of interviews, but no one seems to know why and when to use each of these clauses. Where The where clause is used to filter based on criteria other than aggregates. So say for example...

SQL-IN : A Tool to Quickly Build The In Condition

So after years of copying data to Notepad++, then formatting to use in an IN condition, I decided to create an application to perform that function for me, at a fraction of the time. The tool is called SQL-In and can be used to parse data with common or a custom delimiter, then format to use with an IN condition. The...

SqlDataAdapter Will Not Always Return a Result, SSMS Will

The Issue I ran into a strange issue with an ASP.NET site (MVC2 – 4.0 Framework) where when executing a stored proc, SqlDataAdapter.Fill(DataTable) will not return any rows some of the time, but SQL Server Management Studio will almost immediately return results. The full method calling the stored procedure is below : (Auto-generated from LLBL Pro V2.6) This issue occurs...

View The Last 50 Queries Ran on SQL Server

I ran into an issue where I needed to see the last few queries ran on SQL Server (Currently using SQL Server 2005). There were quite a few suggestions out there, but one I found on Stack Overflow seemed to be formated the best and didn’t require me messing with the query. (See Query Below) This however wasn’t working for...

Cannot find either column “[ColumnName]” or the user-defined function or aggregate “[ColumnName]”, or the name is ambiguous

I had the following, really simple, issue when adding no locks to my join statements. (I’m relatively new to nolocks since my other applications didn’t require almost immediate concurrent access) Note: Tables names were changed obviously And it was throwing Msg 4121, Level 16, State 1, Line 3 Cannot find either column “b” or the user-defined function or aggregate “b.index”, or the...

Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

I don’t know how many times when I was debugging my application which had two databases communicating, I got the following error : Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries. This basically means something updated the row since the last...

Unable to update the EntitySet ” because it has a DefiningQuery and no InsertFunction

I was deploying a build on a cloud test machine with its own SQL Server and data. I was testing a sync function (a mobile handheld grabbing information from a server) and got the following error. Unable to update the EntitySet ” because it has a DefiningQuery and no element exists in the element to support the current operation. What...

Package ‘Microsoft SQL Managment Studio Package’ failed to load

I had  a fresh Windows 7 operating system, SQL Server install, and had just finished installing SQL Server management Studio(SSMS). I tried running SSMS and got the failed to load error. I had noticed when I was researching this error there were a few solutions besides the one I found, so I thought I’d compile them here. Solution 1 : Re-installing SQL...

Installing SQL Server Management Studio (SSMS) for SQL Server 2008

In years past, you could download the SQL Server Management Studio and it was pretty straight forward during the install and you were good to go in minutes. Now they seemed to have made a confusing way to install it which you will spend far too much time trying to figure out. So to save you time, I thought I’d...

%d bloggers like this: