Is there a more efficient way of doing the following SQL?
I want to select the top 50 results, but I also want to set a variable to tell me if I would have gotten more results back without the TOP
DECLARE @MoreExists BIT
SET @MoreExists = 0
DECLARE @Count INT
SELECT @Count = Count(*)
FROM MyTable WHERE ... --some expensive where ...
I'm sure this is a common query but I'm not certain how to phrase it best.
I have two tables:
Questions { Id, Text... }
Answers { Id, QuestionId, Text...}
I would like to retrieve a list of Questions and their Answers, so that the results can be displayed like this:
Question A
1st answer to question A
2nd answer to question A
3rd...
Hi,
Can some body please, give me idea on how can I do a schema compare between the build script in TFS and the database in the server for that build.
Thanks
...
I'm defining a database for a customer/ order system where there are two highly distinct types of customers. Because they are so different having a single customer table would be very ugly (it'd be full of null columns as they are pointless for one type).
Their orders though are in the same format. Is it possible to have a CustomerId co...
Hi Everyone
I just want to know your opinion.
I have here a situation. I have a almost release ready (release in 2 month) application that runs queries on the microsoft Sql-Server database.We use the standard Microsoft jdbc driver implementation for sql-server. Works great,no problems.
Now there come a developer to me and says that i ...
Hi i want to know how to enable remote server connection in sql server 2000. I have sql server 2000 installed in a system with windows server 2003 os. i want to create a dsn connection to the database through remote. I have created a dsn locally in the server it is working. but how to create dsn from the remote system and make it work.
...
Hi Guys
On my test DB, the dates are displayed in a DD/MM/YYYY format. By displayed I mean when you right click, open table in Management Studio, the returned data are displayed in a DD/MM/YYYY format.
Funny thing is, when I write T-SQL to retrieve records, I have to input a MM/DD/YYYY format to get back the right data. Is there anyway...
Are there any alternatives to SQL Server Analysis Services on the Windows x64 platform? I'm vaguely curious, because I haven't heard of any (though admittedly I haven't looked very hard).
Basically, a product that allows multi-dimensional cubes and querying those to generate reports (though the generation and presentation of those repo...
I'd like to know what application connected to DB and executing SPs.
(I want to limit SP execution to only my App - all other - eg MS SSMS would be ignored)
So is there a way to find out connected client name?
If not maybe you have other suggestion how to ensure only dedicated app is used
(App is using Windows' integrated security)
ED...
Hi,
I have a table and want to transpose its rows to columns, similar to a pivot table but without summarising.
For example I have the following tables:
Question
--QuestionID
--QuestionText
Response
--ResponseID
--ResponseText
--QuestionID
Basically I want to be able to create a dynamic table something like:
Question 1 Text | Ques...
Can this be done in bulk too? So that all columns in the table can be set to switch off the 'NOT NULL' flag?
...
I have a hierarchical tree table structure .How can i get the left tree and right tree .
1 a NULL
2 b 1
3 c 1
4 d 2
5 e 2
6 f 3
7 g 3
8 h 4
9 i 4
10 j 5
11 k 5
12 l 6
If i have the id of a ie 1 .how can i get the tree of b and c
i am expecting the tree under b as
2 b
4 d
5 e
8 h
9 i
10 j
11 k
...
Hi all,
I'd like to copy a table's row before updating and I'm trying to do it like this:
CREATE TRIGGER first_trigger_test
on Triggertest
FOR UPDATE
AS
insert into Triggertest select * from Inserted
Unfortunately, I get the error message
Msg 8101, Level 16, State 1, Procedure first_trigger_test, Line 6
An explicit value for the ide...
Let's say there's an application which should create its own tables in main database if they are missing (for example application is run for a very first time). What way of doing this is more flexible, scalable and, let's say, more suitable for commercial product?
If I code it all no additional files (scripts) are needed. User won't be ...
I have several entities that I require users be able to add custom fields to.
If I had an entity called customer with base variables like {Name, DateOfBirth, StoreId}
and another one called Store with {Name}
Then I would want it so that the owner of that store could login and add a new variable for all their customers called favourite ...
We're using SQL Server Standard Edition 8.00.760 (SP3) on a Small Business Server 2003 platform.
While tracking down an inexplainable System.Data.DBConcurrencyException for a Strongly Typed DataSet, I discovered the following problem:
Given is this table:
CREATE TABLE [dbo].[Auszahlung](
[auszahlungid] [int] IDENTITY(1,1) NOT NULL,...
I am using read committed transactions in my asp.net application.
I'm supsicious that somehow when I get to SQL Server read commited isn't being used.
Is there a way to determine via a SQL Trace what the isolation level of a transaction is. All I can see is BEGIN TRANSACTION
...
I am using SQLBulkCopy to move large amounts of data. I implemented the notification event to notify me every time a certain number of rows have been processed, but the OnSqlRowsCopied event does not fire when the job is completed. How do I get the total number of rows copied when the SQLBulkCopy writetoserver completes?
...
I just finished my first C# project in VS 2008 and it is working well now. But now I need to publish this project on my website. This project interacts with my SQL Server 2008 Adventureworks database on this same computer.
I will use this same computer to host the website and house this database. I know HTML but not how to add a .N...
I have a flat data file that I need to import into my SQL Server 2005 DB.
Many of the fields need to be split off into different, related tables. For example, the flat file has names, addresses and telephone numbers, all in one record. In my DB, the Person table has many Telephones and Addresses.
Is there a one-step process whereby I...