sql-server

Difference of two date time in sql server

Hii, Is there any way to take the difference between two date time in sql server for example my first date is '2010-01-22 15:29:55.090' second date is '2010-01-22 15:30:09.153' ...

How to not load ReorderList's InsertItemTemplate on init

Hi There, I have an ajax ReorderList, with some Insert items. on some conditions for some users I would like to hide the InsertItemTemplate, how cand I achieve this? Thanks in advance ...

Generate script for all objects for SQL Server Database

I have used SMO objects to generate SQL Script for database objecrs for SQL Server. This works well when the database is in the local network. But it takes a lot of time if database is in a remote server. What would be the best and fastest way of generating scripts for SQL Server objects when database is in remote server. Thanks in adva...

ReportViewer for SQL Server 2008

VS2008 ReportViewer won't work in local mode with SQL 2008 reports (e.g. created with Report Builder 2.0). As far as I know that Beta2 includes updated report viewer: from this topic it seems that there's redistributable package. The question: is there a way to make the new ReportViewer control to work with VS2008? ...

How to eliminate superfluous namespace declarations in SQL generated XML?

I'm fine tuning a web app that calls SOAP services backed by SQL stored procedure calls. Typically the stored procs generate XML that becomes part of the SOAP response, and that XML has many superfluous xmlns namespace declarations. In pathological cases this can be 30% or more of the char encoded XML measured in bytes, e.g.: <GetFooRes...

How to import data from a file into a single column of a SQL Server database?

I have a very simple table with only one column (+ the key column). This column is a varchar(N) type. I would like to import data from a text file. The file looks like this: string1 string2 . . . stringZ I don't know how to generate a script to insert these values into the table. Or is there an even simplier tool to import in such a s...

Migrating from SQL Server to ORACLE ¿what to do with temporary tables?

Currently we use SQL Server and we have A LOT (read around 5.000) different scripts that create on the fly temporary tables. Now we are migrating to ORACLE, so we cannot create on the fly temporary tables. Any ideas? Thanks in advance ...

Is there any way to make this UDF deterministic?

I assume this is not deterministic simply because DB_NAME() is not deterministic? If DB_NAME() is not deterministic, why is it not deterministic? ALTER FUNCTION [TheSchema].[udf_IS_PRODUCTION] () RETURNS bit WITH SCHEMABINDING AS BEGIN RETURN CASE WHEN DB_NAME() = 'PRODUCTION' THEN CONVERT(bit, 1) ELSE CONVERT(bit, 0) ...

Performant way to get the maximum value of a running total in TSQL

We have a table of transactions which is structured like the following : TranxID int (PK and Identity field) ItemID int TranxDate datetime TranxAmt money TranxAmt can be positive or negative, so the running total of this field (for any ItemID) will go up and down as time goes by. Getting the current total is obviously simple...

Switching Database in LinqToSql

How can we change the underlying database for Linq based WebApp ? for example: When we release our web application, say to release from production, if using ADO.NET, it is as simple as modifying connection string in web.config to point towards the live Database in use. The databases are almost identical, other data stored.. What and h...

Output two columns for 1 field for different date ranges?

Hi, I have a SQL table "ITM_SLS" with the following fields: ITEM DESCRIPTION TRANSACTION # DATE QTY SOLD I want to be able to output QTY SOLD for a one month value and a year to date value so that the output would look like this: ITEM, DESCRIPTION, QTY SOLD MONTH, QTY SOLD YEAR TO DATE Is this possible? ...

Are there any automated white box testing tools for T-SQL stored procedures and/or functions?

I was wondering if there are any tools similar to Pex that analyze T-SQL stored procedures and functions (instead of managed code) in order to generate meaningful and interesting input values for parameterized unit tests. ...

Better to use a Clustered index or a Non-Clustered index with included columns?

When I look at the execution plan for a particular query I find that 77% of my cost is in a Clustered Index seek. Does the fact that I'm using a clustered index mean that I won't see performance issues due to the columns that I am outputting? Would it be better for me to create a Non-Clustered version of this and include all of the c...

Filtering capabilities of WPF datagrid

In a WPF application I need to implement convenient for user possibility of quick and easy search for particular records from a SQL Server database. Please, could you share your expierience and opinion about filtering capabilities of WPF datagrid from a WPF Toolkit, comparing to third-party datagrids? ...

SQL Server 2005 SSIS - How to get special information from the first line of a file

Say I have a text file that looks like this: date 1/1/2010 a,b,c a,b,d ... I want to import it into a table so it looks like this: 1/1/2010,a,b,c 1/1/2010,a,b,d ... What is an elegant way to do that? My best idea so far is to use a data flow package, and use a flat file source to read in the file (ignoring the first line) and lo...

What are the SQL Server requirements for Team Foundation Server And Reporting Services?

I had many problems installing Team Foundation Server 2005 (Workgroup) about six months ago for various reasons, and because other projects have taken priority, I never did finish. On top of that, we are installing a new server and I am now trying to determine what licensing and editions we need to purchase for SQL Server. One of the pr...

How to do multiple aggregated columns in a select statement

Just to head off the quick-repliers, I'll mention that I'm not using MySQL so I can't use GROUP_CONCAT, and that I've also looked at this question already. The example (this is not the data i'm working with but it accurately describes my case) Person table, with ID, Name columns Person_CountriesVisited table, with PersonID, Country colu...

Can the SQL Case Statment fall through?

Is there a way to make a CASE statement in SQL fall through like the case statement in C#? What I don't want to do is the example below but if that’s my only option I guess I'll go with it. EXAMPLE: @NewValue = CASE WHEN @MyValue = '1' THEN CAST(@MyValue AS int) WHEN @MyValue = '2' THEN CAST(@MyValue AS int) ELSE ...

how to get cumulative sum..

Hi all, declare @t table ( id int, SomeNumt int ) insert into @t select 1,10 union select 2,12 union select 3,3 union select 4,15 union select 5,23 select * from @t the above select returns me the following. id SomeNumt 1 10 2 12 3 3 4 15 5 23 How do i get the following.. id srome CumSrome 1 10 10 ...

Data Mining with Sql Server

I have 2 questions about data mining: I have the concepts of this topic But I want to know more about it as I know we can use data mining to find patterns from our database like the common example (sugar and tea:the majority of people buy sugar with tea),but if i want to use data mining technique from another view : I mean I hav...