sql-server

Query to get Max/Min row details for multiple fields

I have a table structure similar to the following example: DateTime V1 V2 V3 V4 10/10/10 12:10:00 71 24 33 40 10/10/10 12:00:00 75 22 44 12 10/10/10 12:30:00 44 21 44 33 10/10/10 12:20:00 80 11 88 12 With DateTime field being the unqiue and key field, I want...

Sql Ordering Hiarchy

I am working on a SQL Statement that I can't seem to figure out. I need to order the results alphabetically, however, I need "children" to come right after their "parent" in the order. Below is a simple example of the table and data I'm working with. All non relevant columns have been removed. I'm using SQL Server 2005. Is there an ...

ROW_NUMBER() OVER Not Fast Enough With Large Result Set, any good solution?

I use ROW_NUMBER() to do paging with my website content and when you hit the last page it timeout because the SQL Server takes too long to complete the search. There's already an article concerning this problem but seems no perfect solution yet. http://weblogs.asp.net/eporter/archive/2006/10/17/ROW5F00NUMBER28002900-OVER-Not-Fast-Enoug...

Advice on using a web server as a cache

I'd like advice on the following design. Is it reasonable? Is it stupid/insane? Requirements: We have some distributed calculations that work on chunks of data that are sometimes up to 50Mb in size. Because the calculations take a long time, we like to parallelize the calculations on a small grid (around 20 nodes) We "produce" around ...

How to use a single SQL DB Connection string?

Hello, I am developing an ASP .NET application on my PC and deploying it on a host. The application uses a Microsoft SQL DB, I have two databases one local and one on a server. How should the application be configured so it could connect to both DBs without any code changes? (the 2 databases have identical names and structure) Thanks...

Linq-to-sql: How to actively grab linked objects?

So I have a tree structure in a SQL-Server database. Each node is linked to its parent by a foreign key called prev, to another node. I would like whenever I fetch a node, for all nodes leading to the root of the tree to be fetched as well. Currently I can do it like this: MyDataContext db = new MyDataContext(); IList<N...

complete sync between iphone sqlite3 database to sql server 2005 database on the server

Hi, I hava a sqlite3 database placed in the documents folder. I need to sync this database with the sql server 2005, which is running at our server. Is there a possibility that i can do a Replication between a sqlite3 database and a MSSql server 2005. -- Regards, Syed Yusuf ...

Unique date range fields in SQL Server 2008

I have a table that consists of, among other things, two fields named StartTime and EndTime. Both are TIME fields. I want to add a constraint preventing the insertion of any records that overlap with preexisting time ranges. E.g. if a record already exists with StartTime = 5:00, EndTime = 10:00, I would want an insert with StartTime = 6...

LINQ to SQL "1 of 2 Updates failed" on "SubmitChanges()"

I am updating an object of type X and its children Y using LINQ to SQL and then submitting changes and getting this error Example Code X objX = _context.X.ToList().Where(x => x.DeletedOn == null).First(); objX.DeletedOn = DateTime.Now; EntitySet<Y> objYs = objX.Ys; Y objY = objYs[0]; objY.DeletedOn = DateTime.Now; _context.SubmitChan...

Can I temporarily store data in my C#.Net app to reduce the need for calls for data from SQL Server?

I created a C#.net app that uses dates from a sql server 2008 database table. Is there a way for me to temporarily store the data so that my program does not have to repeatedly make server calls for the same set of information. I know how to pull the info I need and create a temporary dataset, however, it is only accessable to the part...

Getting all possible combinations which obey certain condition with MS SQL

I need to constract an SQL query but I have no idea how to do it. If someone helps, I'll appriciate it very much. I have the following table GroupedBYField ConditionField ToBeSummeField 1 1 1 1 1 2 1 ...

how do I connect to database on server over ip

We have our sql database on a server (remote) . I have various clients at different location who have windows application (exe ) installed on their pc.How do we connect to the server .Should I go for change in connection string contaning ip address or ceate webservices for accessing database.Please provide me your suggest...

How to backup SQL Server 2008 database - only the objects, without data

How to backup SQL Server 2008 database - only the objects, without data thanks in advance ...

sometimes Identity isn't working.

Hi, I have a following table CREATE TABLE [dbo].[test_table] ( [ShoppingCartID] [int] IDENTITY(1,1) NOT NULL, [CartTimeoutInMinutes] [int] NOT NULL, [MaximumOrderLimitPerUser] [int] NOT NULL, [MaximumOrderLimitPerSession] [int] NOT NULL, CONSTRAINT [PK_test_table] PRIMARY KEY CLUSTERED ( [ShoppingCartID] ASC ) WITH (PAD_INDEX = ...

DataAdapter Update() requires input parameter for Auto increment primary key column

While updating a DataTable to a SQL Server database I get the error message "Column 'PK_Column' does not allow nulls" after calling GetErrors() I don't want to provide a value for PK_Column because it is a auto increment primary key column in the database. My insert statement looks like this: INSERT INTO [Order] ([Customer_Id], [OrderTi...

How should i work in this scenario . Should I use Trigger or Leave on User to manage

I am creating an application in which i am using stored procedure where i m implementing my logic. Now what i need to know is that- i want my database not to contain any invalid entry, for this purpose should i create triggers, for implementing my data validation logic such that when FailPasswordAttemptCount is changed to some value th...

Choosing where to attach a foreign key between two tables?

I have a purchase order table and another table to contain the items within a particular purchase order for drugs. Example: PO_Table (POId, MainPharmacyID, SupplierID, PreparedBy) PO_Items_Table (POItemID, ...) I have two options of choosing which table to link to which and they seem both valid. i have done this a number of times and...

function for calculating working week SQL Server

I have a similar question posted, but did not quite get the answer I needed I have the following sql code which gets built up in a c# app... This code works fine, except for when the date range is bigger than 1 working week. I need to edit the code so that when the CSIAchieved date falls into the next working week it is 'outside' of SLA...

Import typed DataSet to SQL Server

Dear guys I want to import a typed DataSet with DataTables (not with TableAdapters) to my SQL Server database. The structure of all DataTables in the DataSet is the same like in the SQL Server database. With the same fields. How can I import the whole typed DataSet to my SQL Server database? Best regards ...

Getting the Nth most recent business date - very different query performance using two different methods

I have a requirement to get txns on a T-5 basis. Meaning I need to "go back" 5 business days. I've coded up two SQL queries for this and the second method is 5 times slower than the first. How come? -- Fast with BizDays as ( select top 5 bdate bdate from dbo.business_days where bdate < '20091211' order by bdate Desc ) ,BizDate ...