sql-server

Reporting System Architecture

We have built enterprise/LOB software that, for example, manages orders, customers, inventory, etc. in .NET 3.5 and SQL Server 2008. We do all kinds of reporting such as traditional reports (SQL queries) dashboards (with charts, lists, etc.) alerts (e.g. if an order is cancelled, email a supervisor) Right now, we are querying our op...

In Linq to SQL is it better return multiple results sets at once or call the DB using multiple stored procedures?

I am creating a very data intensive, high volume web site. Every aspect of the website is driven by interactions with the MSSQL DB that I am using. On one page there are 10-12 different resultsets that I need to utilize in my page. So I need to know the best practice when it comes to using Linq-to-SQL and multiple results sets with a ...

Connecting to sql server database mdf file without installing sql server on client machine ?

I am creating a window application that need to use sql server database. I want to install this application to client machine without installing sql server so that my application can still connect to a database i.e mdf file that i will be providing at client system. How can i connect to a database(mdf) on client machine through my win...

ASP.NET MVC authentication using custom database instead of ASPNETDB?

I already have a User table in my primary application database with an email address (which will act as the user name) and a password. I would like to authenticate using my database instead of the default authentication database (ASPNETDB). Questions: Is this a bad idea? Is it a huge can of worms to use my own DB for authentication? H...

how to get the number on months between two dates in sql server 2005

i have a column in my sql server 2005 table that should hold the number of months an employee has been in service. Since i also have the date the employee was engaged, i want the "months_In_Service" column to be a computed column. now if i use datediff(month,[DateEngaged],getdate()) as the formula for the months in service computed colum...

Insert data into sqlserver 2000 database, the order change, why ?

Insert 200 data througn for-loop into sqlserver 2000 database, the order change, why ? When I use mysql, it doesn't have the matter. i mean: when you insert 2, then insert 3, then insert 1, in mysql you will see 2,3,1 like the order you insert. But in sqlsever2000 that may not. ...

SQL Server select where datetimeoffset older than 1 hour

I know this should be easy and I do it no probelms in mySQL and Postgresql but I'm struggling with SQL Server. I want to select rows with a datetimeoffset field that's over an hour old. select * from table where mydatetime < getdate() - 1 hour I've tried dateadd and datediff but can't get it right. ...

Can I be a deadlock victim if I'm not executing a query within a transaction?

Lets say I open a transaction and run update queries. BEGIN TRANSACTION UPDATE x SET y = z WHERE w = v The query returns successfully and the transaction stays open deliberately for a period of time before I decide to commit. While I'm sitting on the transaction is it ever possible the MSSQL deadlock machinary would be able to preemp...

Getting All the record of particular month - Building SQL Query

Hi all, I need some help to build SQL Query. I have table having data like: ID Date Name 1 1/1/2009 a 2 1/2/2009 b 3 1/3/2009 c I need to get result something like... 1 1/1/2009 a 2 1/2/2009 b 3 1/3/2009 c 4 1/4/2009 Null 5 1/5/2009 Null 6 1/6/2009 Null 7 1/7/2009 Null 8 1/...

Detect which dataset row violates the DB unique constraint during insertion

I'm inserting rows into a table from other tables in the SQL Server management Studio and some records violates a unique constraint because initial data is 'dirty' and is inconsistent. How can I find which records violate? ...

DROP SQL Tables if created date is more than a week - MS SQL Server

Hi, I want to create a Stored procedure and Job in Ms SQL server that would delete all tables in a schema that are more than a weeks old. i create backups every single day and i want to automate the process by scheduling a job to delete any backups(SQL Tables) that are older than a week. Your help would be greatly appreciated. ...

SQL WITH Statement, Unknown Column in where clause

Hi all, I ve got the following query which is throwing the following error Unkown Column 'RowNum' WITH Employees AS ( SELECT (keyTblSp.RANK * 3) AS [Rank], sp.*, addr.Street, addr.PostOfficeBox, addr.StreetNumber FROM Employee sp INNER JOIN FREETEXTTABLE(Employee, *, 'something', 1000) AS keyTbl...

SQL Server 2008 + C# + Inno Installer

Hi there! First off I´m new here, so, I'd say HELLO EVERYONE and thanks for years of helping. I have the following problem: I need create a installation of a C# app that uses SQL Server 2008. I am using InnoSetup Installer because I thought it could be the best choice, but I have no clue how to install SQL Server 2008, and several dat...

Migrating data from SQL Server to mysql using inserts

I am trying to migrate data from SQL Server to mysql, and i'd like to do that using insert-statements, so i modified this nice script by Narayana Vyas Kondreddi to generate mysql-friendly code and everything works fine so far. the problem being columns of the TEXT datatype that can be more than 8000 characters long (containing long blo...

SQL Recursive Coalesce

Hi all, I'm trying to create a column that contains all cities of the referenced addresses. DECLARE @AddressList nvarchar(max) SELECT @AddressList = COALESCE(@AddressList + ' ', '') + City FROM [Address] SELECT Employee.*, (SELECT @AddressList) AS AddressCities FROM Employee But I dont know where to put the WHERE clause. ...

Patterns for handling a SQL deadlock in C#?

I'm writing an application in C# which accesses a SQL Server 2005 database. The application is quite database intensive, and even if I try to optimize all access, set up proper indexes and so on I expect that I will get deadlocks sooner or later. I know why database deadlocks occur, but I doubt I'll be able to release the software withou...

SQL Server 2005 select for XML path with union in sub-selection problem

Hi There, I'm rather experienced with SQL server "select for XML path" queries but now i run into a strange problem. The following query works fine: select ( select 'Keyfield1' as "@Name", t1.Keyfield1 as "Value" from MyTable t1 where t1.KeyField1= t2.KeyField1 and t1.KeyField2= t2.KeyField2 for xml...

SQL Server datatype precision - Neo, what is real?

SQL Sever 2000 documentation: Is a floating point number data with the following valid values: –3.40E + 38 through -1.18E - 38, 0 and 1.18E - 38 through 3.40E + 38. Storage size is 4 bytes. In SQL Server, the synonym for real is float(24). SQL Server 2005 documentation: The ISO synonym for real is float(24). EDIT: G...

Counting records in SQL Server

Hello friends, Take a look at this SP. ALTER PROCEDURE [dbo].[sp_GetRecTitleVeh] AS BEGIN select a.StockNo, c.ClaimNo, v.VIN, v.[Year],v.Make, v.Model, c.DOAssign, t.DOLoss, t.RecTitleDate From dbo.Assignments a, dbo.Assignment_ClaimInfo c, dbo.Assignment_TitleInfo t, dbo.Assignment_VehicleInfo v Where ...

SQL Server: How does the type of an index affect a join's performance?

If I'm am trying to squeeze every last drop of performance out of a query what affect does having these types of index's being used by my joins. clustered index. non-clustered index. clustered or non-clustered index with extra columns that may not be involved in the join. Will I gain any performance if I go through and create cluster...