Skip to content
Advertisement

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 the primary key

Only inserting a row if it’s not already there

I had always used something similar to the following to achieve it: …but once under load, a primary key violation occurred. This is the only statement which inserts into this table at all. So does this mean that the above statement is not atomic? The problem is that this is almost impossible to recreate at will. Perhaps I could change

select from access database file and insert to sql Database

I have an access database file (test.mdb) and I need to write a stored procedure which will select some records from tblTest in test.mdb and insert them into tbsqlTest in my sql database . ==> I need a SP like this : Answer If you’re willing to permit Ad Hoc Distributed Queries on your SQL Server, you could use OPENDATASOURCE

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 North, then

Is there a combination of “LIKE” and “IN” in SQL?

In SQL I (sadly) often have to use “LIKE” conditions due to databases that violate nearly every rule of normalization. I can’t change that right now. But that’s irrelevant to the question. Further, I often use conditions like WHERE something in (1,1,2,3,5,8,13,21) for better readability and flexibility of my SQL statements. Is there any possible way to combine these two

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 number of rows

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, it will just be idle. It works

Advertisement