sql-server

Linq or Stored proc - Which should I choose?

An Activity occurs at a location on a specific date, but each activity may be repeated at the same or different locations on different dates. I have created an entity framework model, and wish to populate it with relevant Activities which occur between two dates, ordered by the locations distance from a specified location. I therefore ...

Is it Possible to Backup and Transfer files through T-SQL using SSIS

Here is a situation, There is SERVER A and SERVER B, SERVER B wants to restore backup taken by SERVER A on its own local machine now I know I have a little bigger way to setup FTP etc to transfer the FILE but I want to know that can I write a SSIS Package which would do file transfer from SERVER A to SERVER B without depending upon FTP/...

eligibility for creating index

I have created script to find selectivity of each columns for every tables. In those some tables with less than 100 rows but selectivity of column is more than 50%. where Selectivity = Distinct Values / Total Number Rows So, is those column are eligible for index? Or, can you tell, how much minimum rows require for eligibility for creat...

How to use C# to add a column for a table of sql server?

How to use C# to add a column for a table of sql server? For example, I want to execute the following sql in C# code: alter table [Product] add [ProductId] int default 0 NOT NULL ...

Is SQL Server 2005 faster when table relationships are defined ?

I heard that SQL is faster if table relationships are defined. Is this true? Or maybe it's slower, I would like to know. ...

How to monitor tables in SQL Server for changes

This question was asked quite some time ago, and while it covers possible solutions for SQL 2005 and 2008, it lacks a good solution for SQL 2000, which is still far too common. I need a way to monitor certain fields of a database table for changes, and notify my application when these changes occur so that I can blast them out on the lo...

SQL 2008 HierarchyID with Multiple Root Nodes

I wanted to use the new HierarchyID type in SQL Server 2008 to handle the page relations in a small wiki application. However It would need to have multiple root nodes since every main article/page per account would be a root node. From what I have read the HierarchyID type only allows 1 root node per column is this correct? and is the...

Cannot add database to an Asp.Net application

Hello everyone, I'm unable to add an mdf database file by right clicking on the project name and clicking on "Add->New Item->SQL Server Database". It gives me the following error... ** Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the compone...

"UPDATE failed because the following SET options have incorrect settings: 'ARITHABORT'

SaveOrUpdate using nHibernate is getting the following error. UPDATE failed because the following SET options have incorrect settings: 'ARITHABORT' If I set arithabort on: var command = session.Connection.CreateCommand(); command.CommandText = "Set Arithabort on"; command.ExecuteScalar(); Instead of getting the update failed, I ge...

SQL Server is extremely slow when running queries on the Stack Overflow data dump

I imported the Stack Overflow data dump into SQL Server 2008. Some queries, especially on the Posts table, are taking more than a minute to return. Example query: SELECT Id, PostTypeId, AcceptedAnswerId, CreationDate, Score, ViewCount, Body, OwnerUserId, OwnerDisplayName, LastEditorUserId, LastEditDate, LastActivityDate, Tit...

See what caused a SQL trigger?

I just wonder if it is possible to see what stored procedure or SQL statement that caused a trigger to be executed somewhere in the trigger. I have a really wierd bug where a field is changed and i can't for my life figure out why that is happening. I have a trigger that is logging that the data is changed but it would be great if i als...

How to convert a database file (.sql) to a .mdf file?

I have a database that was given to me, but is in a file format (.sql). I want to open it in my SQL Server, but I don't know how, because it says i need a .mdf file? Can someone help? ...

How to Insert row between two rows and give it priority in database ?

Hi everyone!. i have a stack of messages in database table. i want to send these messages by their priority so i added "Priority" column to "messages" table. but what if i want to insert "cram" message between two messages and give the previous priority to this new message?. Should i update all messages priority under this message. S...

SQL Server CE or Access for a portable database with c#?

Hello, I'm developing an application which needs to store large amounts of data. I cannot use SQL Server Express edition since it requires separate installation and our target customers have already loaded us with complaints about our previous release with SQL Server express. Now my choices are between SQL Server compact and Access. ...

timeout setting for SQL Server

Hello everyone, I am using VSTS 2008 + ADO.Net + C# + .Net 3.5 + SQL Server 2008. I am using ADO.Net at client side to connect to database server to execute a store procedure, then return result from the store procedure. Here is my code. I have two issues about timeout, If I do not explicitly set any timeout related settings, for the...

TooManyRowsAffectedException with encrypted triggers

I'm using nHibernate to update 2 columns in a table that has 3 encrypted triggers on it. The triggers are not owned by me and I can not make changes to them, so unfortunately I can't SET NOCOUNT ON inside of them. Is there another way to get around the TooManyRowsAffectedException that is thrown on commit? Update 1 So far only way I'...

Develop for SQL Server Standard using SQL Server Express?

I'm working on a web service project, and I'm coding at home, where I have SQL Express 2008 installed, but the app needs to interface with an SQL Server Standard. I've never done the transition before, and I haven't been able to find any resources on the subject - plenty of stuff about upgrading, but nothing about how to deploy. For ins...

Issues with Fluent Nhibernate Automapping in version 1.0RC

I am new to NHibernate and am running into some issues getting the Automap functionality to work properly. Here are a couple of issues I am having. The getting started wiki for Fluent NHibernate (http://wiki.fluentnhibernate.org/Getting_started) defines a sample with store, product, and employee classes--as well as the mapping for thos...

SQL make rows into columns, PIVOT maybe

Hi I have an MS SQL Server with a database for an E-commerce storefront. This is some of the tables I have: Products: Id | Name | Price ProductAttributeTypes: -Color, Size, Format Id | Name ProductAttributes: --Red, Green, 12x20 cm, Mirrored Id | ProductAttributeTypeId | Name Orders: Id | DateCreated OrderItems: Id | Ord...

DSN tests ok, but login failure trying to use the DSN to SQL Server 2005

I'm writing a small ASP.NET application in a hosted environment (meaning I don't own the server). Using the hosting provider's webtools, I created a DSN that specifies the Driver, the Server, the UID, the PWD, and the Database. When I test the connection, it tests out fine. However, when I load my web page with the code: OdbcConnecti...