sql-server

Going from SQL database to CRUD (and getting there quickly)

I'm running VS2010, IIS7 w/ SQL Server 2008; programming a web application in C#. So, I've got my database with all relationships carefully mapped; it has about 25 tables with 6 different schemas (e.g. [Account], [Customer], [Product], [Category], [Vendor], etc). What tools, methods, and architectures are commonly used to quickly go fr...

Find the minimum flow in a day and the time it occurs

using MSQL 2005 I have a continuous set of flow measurements (averaged for each 15 minute time slice) I am trying to write a query to find the minimum flow for each day and the time it occurs Finding the minimum flow is easy but getting the time is harder. Currently I do this: select d1.data_point_groupid , min(d1.timeID) [timeI...

How do I debug Query Notifications on SQL Server?

I am trying to get query notifications to work, but my application is not receiving any notifications. How do I debug Query Notifications? I am using the code availble here http://www.codeproject.com/KB/database/chatter.aspx. I can see that the queues, the services and the stored procedures are being created on the server, but the OnCha...

Performace gains of searching with FTS over it with LIKE on indexed colum(s)?

Subquestioning "full-text search sql server 2005" Would the use of FTS (Full Text Search) be faster in comparison with searches using tsql LIKE on indexed column(s)? Why? And how much? ...

How to change sqlConnectionString for sessionState in SQLServer mode at runtime?

Hello, We're trying to find a way to change the sessionState's sqlConnectionString (in SQLServer mode) at runtime. We're implementing a fail over for our SQL server and we want to catch when the sessionState fails to have access to my SQL server and tell it to fail over to my secondary server and initialize the site-wide fail over at th...

Not-found="ignore" behaviour in Castle Activerecord

Is it possible to implement the 'not-found="ignore"' behaviour of NHibernate on a key mapping when using Castle Activerecord? I am using existing legacy Castle Activerecord classes within an ASP.Net web application to map to a legacy, read only, MSSQL database. I cannot alter the database in any way. The parent Product table has a rela...

Parallel.ForEach throws exception when processing extremely large sets of data

My question centers on some Parallel.ForEach code that used to work without fail, and now that our database has grown to 5 times as large, it breaks almost regularly. Parallel.ForEach<Stock_ListAllResult>( lbStockList.SelectedItems.Cast<Stock_ListAllResult>(), SelectedStock => { ComputeTipDown( SelectedStock.Symbol ); } ); The Com...

Query by Date/Time in SQL Server 2005

Hello, I have such a simple question, I feel stupid for asking it. I can't believe I'm hitting my head on this. I have a table called "Orders". "Orders" has a smalldatetime field called "DateOrdered". I need to get all of the "Orders" on a specific date. I have tried the following without any success: SELECT * FROM Orders WHERE [DateO...

Running MSSQL Stored Procedures via ODBC (And getting the results back) with PHP

My work is in the process of moving all of our PHP web applications off of our Windows production web server to a new Linux server environment specifically for PHP apps. The sticky part is, several of the PHP applications we're running are using MSSQL databases, and therefore all the DB connectivity has to be re-written to use unixODBC/F...

declare variable for query string

Hey all, i was wondering if there was a way to do this in MS SQL Server 2005: DECLARE @theDate varchar(60) SET @theDate = '''2010-01-01'' AND ''2010-08-31 23:59:59''' SELECT AdministratorCode, SUM(Total) as theTotal, SUM(WOD.Quantity) as theQty, AVG(Total) as avgTotal, (SELEC...

Best strategy for storing documents in SQL Server 2008

One of our teams is going to be developing an application to store records in a SQL2008 database and each of these records will have an associated PDF file. There is currently about 340GB of files, with most (70%) being about 100K, but some are several Megabytes in size. Data is mostly inserted and read, but the files are updated on oc...

SQL Server NULL constraint

Is is possible in SQL Server 2008 to create such a constraint that would restrict two columns to have NULL values at the same time? So that Column1 Column2 NULL NULL -- not allowed 1 NULL -- allowed NULL 2 -- allowed 2 3 -- allowed ...

Can MAXDOP be set for just a stored procedure?

I have a stored procedure that contains many 'SELECT' comands. Instead of putting 'OPTION (MAXDOP 8)' at the end of every select command, is there a way I can set it at the start of the stored procedure and remove it at the end, without actually setting it on the server? ex. sp_configure 'max degree of parallelism', 4 go reconfigure wi...

Non-LinqToSQL object management for updates / deleted via "proper" OO

Hi there, I have a Questionnaire, which has questions. It's a very simple data model as I'm sure you can image, with a PK - FK join between the Questionnaire (parent) and Question (child) tables. Modelling this in C#, I have a Questionnaire God-object which has static methods to Create, Get, List, Update, Delete the Questionnaire inst...

Help with insert query which replaces an original id with different value in sql ?

UPDATE: Adding more Employee and ReplacementEmployee Table Employee - EmployeeId SerialNo ----------------------------- 1 11111 34 23233 23 13234 Table ReplacementEmployee- ReplacementId SerialNo ----------------------------- 11 11111 23 23233 13...

Stored procedure call with an ISNULL in the assignment. Invalid Syntax?

Above the call to this stored procedure is another call to a different stored procedure. The first procedure will assign something to @NewIdentifier if it needs to, otherwise I need to use the default SaleId. exec myStoredProc @SaleId = ISNULL(@NewIdentifier, @SaleId) It works if I do it this way declare @Id int set @Id = ISNULL(@New...

SQL:Getting count from many tables for a user record in USER table.Whats the best approach ?

I have 4 SQL server(2008 version) tables 1) USER- to store user information (Fields : UserId,UserName) 2) FILES - to store files uploaded by user (FileId,FileName,UserId) 3) PHOTOS -to store files uploaded by user (PhotoId,PhotoName,UserId) 4) GROUPS= to store groups created by user ( GroupId,GroupName,UserId) Now I want to get a USE...

How do I solve a connection pool issue?

I have recently started encountering Database connection issues with SQL Server on my development machine. System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool How can I monitor the connection pool to figure out what is happening? Further Info: I haven't had m...

how can I use loop 'for' through a table in SQL to check if a column is 0?

how can I use loop 'for' through a table in SQL to check if a column is 0? I need to do like this in a stored procedure: for each record in tablex if table.column1=0 then insert into table1; Else insert into table2; End for; ...

What are locking, deadlocking issues in financial operations?

Subquestioning SQL - when should you use “with (nolock)” In one local financial institution I was rebuked by their programmers for expressing them my opinion that (their programmers' obsession with) (b)locking issues in their MS SQL Server 2005 database(s) did not make much sense to me. What are the possible issues with possible locki...