Skip to content

Tag: sql-server

Is a Primary Key necessary in SQL Server?

This may be a pretty naive and stupid question, but I’m going to ask it anyway I have a table with several fields, none of which are unique, and a primary key, which obviously is. This table is accessed via the non-unique fields regularly, but no user SP or process access data via the primary key. Is th…

Is a Union Query needed

I need a little help writing a query. I have this data… I need to query the data and have an output something like this The idea here is to select the direction, the LowNum and then the nextNumber. Also when the direction changes to start over. (That’s why I think I need a Union, maybe get the Nor…

Simple check for SELECT query empty result

Can anyone point out how to check if a select query returns non empty result set? For example I have next query: Should I do something like next: to test if result set is not empty? Answer Use @@ROWCOUNT: According to SQL Server Books Online: Returns the number of rows affected by the last statement. If the n…

What is Service Broker in SQL Server?

What is Service Broker in SQL Server and is it meaningful to enable it in a simple database, not in a distributed database? Answer SQL Service Broker is an extension mechanism that allows you to queue events for asynchronous processing. There is no intrinsic harm in enabling the broker. If it’s not used…