sql-server

How do you send lists of values in a SQL Server select statement programmatically in a nice way?

Hi, My program generates a list at runtime of values. I need to send a sql query that looks in a table for entries that have a column that contain one of the values in the list. I can't use the usual chain of OR's because I don't know how big the list will be. Is there a nice way to use an array or some IEnumerable to build a SQL statem...

Equivalent of Debug.Assert for SQL Server

I'm adapting a large number of SQL Server 2005 scripts to merge two of our databases together. The scripts are run from a .cmd file which calls sqlcmd to run the scripts in order. However, I'm experiencing one or two issues where the scripts are failing. I'd like a quick way to get a look at the state of some of the scripts where they g...

Algorithm for almost similar values search

I have Persons table in SQL Server 2008. My goal is to find Persons who have almost similar addresses. The address is described with columns state, town, street, house, apartment, postcode and phone. Due to some specific differences in some states (not US) and human factor (mistakes in addresses etc.), address is not filled in the s...

MySql and SQL Server resources utilization comparision

Does Apache with MySql will use less system resources (RAM, CPU utilization) if we develop a web application instead of IIS with Sql Server? My friend told that MYSQL consume very less when compared to SQL Server. I have both PHP and ASP.NET skills. Which one will be preferable to develop application? ...

SQL Server, Converting a select mechanism from "and" into "or"

Hello all, I have a web based program which chooses some records from a database using a checkboxlist. (my check box list sends parameters to a stored procedure and I use the result of stored procedure). Here how my check box list looks like Overflow [] (sends param1) Open Records [] (sends param2) Records with 4...

Alter SQL Server table column width with indexes

I am using SQL Server 2008 and need to alter a large number of columns across many tables from decimal(9,3) to decimal(12,6) The issue I currently have is that some tables have several indexes on these columns and the alter statement fails due to the index. Is there a way to alter the column without losing the index? I am altering the...

Composite Clustered Index in SQL Server

Hi, I have a table with a IDENTITY Column as Primary Key (a classic ID column). SQL Server create automatically a Clustered Index for that Primary Key. My question is: Can I have a only single CLUSTERED INDEX composite with more columns? If yes, how can I drop the default clustered index and recreate a new one with this attributes...

Generate XSD from SQL Server database in order to import XML data

Is there a tool to generate an XSD schema from SQL Server database ? This XSD would be used for importing XML data into database with BULK INSERT or bcp ...

SQLXML without XML encoding?

Hi, I'm using a generic system for reporting which takes data from a database view (SQL Server 2005). In this view I had to merge data from one-to-many relations in one row and used the solution described by priyanka.sarkar in this thread: Combine multiple results in a subquery into a single comma-separated value. The solution uses SQLX...

SQL Server 2008 execution plan question

Hello, I have a question addressed to sql guru. There are two tables with almost identical structure. Based on parameter passed into the stored procedure I need to collect data from one or another table. How to do that in a best way? Please do not suggest to combine those tables into single one - that is not appropriate. I did it ...

How do I merge excel cells using ASP

hi, I am using ASP to Import data from SQL server and then export it to excel. I though want a header text in row 1 ie cells a1 to n1 But how do I write command that can merge those fields ? then I would be able to insert my header txt. I have this asp code: 'setup the excel file Dim objFSO, objExcelFile Set objFSO = CreateObject("Sc...

StyleCop equivalent for SQL Server?

Is there any tools like StyleCop for SQL Server? We need the same features of StyleCop (enforce a set of style and consistency rules). [Additional Feature]: Integration with SQLServer Management Studio would be cool. ...

debugging SSIS packages - debug.writeline

The debugging experience in SSIS is not what I am expecting. I have a script Task that I have added a Imports System.Diagnostics' at the header of the class, and in the code I have various debug.writeline ("Attemtpting to move file") type messages. But, they are not displaying in the output window. Am I missing something ? ...

Developing with SQL Server Express and delpoiyng with SQL Server 2008?

I'am developing a web application with VS2010 Entity Framework and SQL Server Express. This application will be deploiyed in a server with SQL Server 2008 (not express) It is possible? What changes (if needed) i need to do? ...

nhibernate multicriteria CTE subquery

I currently have a MultiCriteria query, which filters the results based on the ids being within a sub query Subqueries.PropertyIn("Id", detachedCriteria) The sub query is the same for all queries used in the multicriteria query. It seems a bit ugly looking at the sql that the sub query is repeated, in my current case 15 times. The r...

Round *UP* to the nearest 100 in SQL Server

Is it possible to easily round a figure up to the nearest 100 (or 1000, 500, 200 etc.) in SQL Server? So: 720 -> 800 790 -> 800 1401 -> 1500 ...

SSIS suitability

I'm tring to create an SSIS package to import some dataset files, however given that I seem to be hitting a brick wall everytime I achieve a small part of the task I need to take a step back and perform a sanity check on what I'm trying to achieve, and if you good people can advise whether SSIS is the way to go about this then I woul...

SQL Server Conversion Exception: Error converting data type varchar to numeric

I am working on a project where the goal is to convert an existing application to SQL Server. However, I am running into issues with ID generation - specifically, the conversion of data types. The hibernate annotations for my ID column are as follows: @Id @GeneratedValue(generator="ID_GEN", strategy=GenerationType.TABLE) @TableGenerato...

Stored Procedure

Hello, i'm stuck with creating a stored procedure that should update a calculated column daily. Unfortunately my knowledge about stored procedures is limited but it seems to be the right place. I try to give more background informations: The Main-Table stores claims and is called tabData. It has a column 'IsReturn' with datatype bit(b...

SQL Server composite key problem

I have 2 tables: create table numbers2 ( id1 int IDENTITY(1,1) not null, id2 int not null, primary key(id1, id2) ) and table 2 create table ttt ( id int identity(1,1) not null, first_name varchar(50) null, last_name varchar(50) null, sex varchar(1) check (sex in ('m', 'f')) null, number_id int not null, id_id1 int not null, id_id2 i...