Skip to content

Tag: sql

Join one row to multiple rows in another table

I have a table to entities (lets call them people) and properties (one person can have an arbitrary number of properties). Ex: People Properties I would like to write an efficient select that would select people based on age and return all or some of their properties. It’s also acceptable to return one of the properties and total property count.

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

set sql server connection to readonly?

How do I set a SQL server connection to readonly? I tried Googling and all I found was File Mode=Read Only, but it didn’t work (File Mode keyword not supported). The reference looked SQL CE specific. No luck with SQLite Read Only=True either. -edit- My connection string is below. I have no clue when it comes to configuring the tables.

Passing combobox value into SQL query in MS Access

I have a combobox in a form, and I want the text of the combobox to be passed into a query. My query is: The form’s name is Enter Data and the combobox’s name is comboCup. Should i do this: or this? Answer You should use [Forms]![Enter Data]![comboCup]. As @Remou has said, the .Text property of an Access control is

Avoiding Nested Queries

How Important is it to avoid nested queries. I have always learnt to avoid them like a plague. But they are the most natural thing to me. When I am designing a query, the first thing I write is a nested query. Then I convert it to joins, which sometimes takes a lot of time to get right. And rarely

is it possible to select EXISTS directly as a bit?

I was wondering if it’s possible to do something like this (which doesn’t work): select cast( (exists(select * from theTable where theColumn like ‘theValue%’) as bit) Seems like it should be doable, but lots of things that should work in SQL don’t 😉 I’ve seen workarounds for this (SELECT 1 where… Exists…) but it seems like I should be able