sql-server

How it is possible to create clustered index on a view.

How it is possible to create clustered indexes on a view in SQL Server 2008. View is not a real table so there is no sense in physical arrangement of the data that clustered index creates. Where do I miss the point? ...

EAV over SQL Server

I'm interested in playing around with the EAV model over an SQL Server Database. Is anybody able to point me to an article or framework for an existing model/schema (I'm not intrested in Saas for this)? ...

Start and Stop SQL Server on my development laptop

I have SQL Server Express on my laptop. I only need to hit it every few weeks. Running SQL Server sucks up a fair bit of memory on my laptop so I was wondering what is the easiest way to turn off SQL Server when not using it? What I have done thus far is to create two batch files on my desktop. One brings SQL Server up with this comman...

Track SQL Server 2005 meta changes?

I know SQL Server 2008 can do this, but essentially I need a way to log all the changes made to a database. I don't need to log selects, and I don't need to log the user, the only important data is what has been added or changed, both with regard to data and structural changes like columns, tables, and indices. What are my options? ...

Order a query based on a field pointing to the same table

Hi all, I have a table called "Sentence" that has the following fields: ID <--- OK NextID <--- FK To ID Text So if I had the following records: *ID* *NextID* *Text* 1 12 The quick 3 40 jumps over 5 null lazy dog. 12 ...

Trying to delete duplicate entries in SQL database deleted all the records. What went wrong?

I tried to delete duplicate records in my DB. The only difference is the PrimaryKey which is a uniqueidentifier. I have about 1500 entries that have been duped so in all I'm looking at around 3000 entries. So I sectioned off about 60 entries (based on the receivedOn date) and executed my code to pare them down to 30 and OH CRAP the 30...

PHP: Remove unprintable characters without removing white space.

I know this a common question but everything I found seems to remove white space. I'm looking for a regular expression that will strip unprintable characters WITHOUT changing any whitespace. This a function that all user input will be filtered through, which means all the characters you could normally type on a keyboard are valid. Ex: t...

Choice of primary key type

I have a table that potentially will have high number of inserts per second, and I'm trying to choose a type of primary key I want to use. For illustrative purposes let's say, it's users table. I am trying to chose between using GUID and BIGINT as primary key and ultimately as UserID across the app. If I use GUID, I save a trip to databa...

T-SQL trigger effect a change before calling other code

I have a table, let's call is [MYTABLE], with an FOR INSERT, UPDATE trigger. The trigger needs to execute a stored procedure, which will do some work based on the changes made to [MYTABLE]. I can't move the stored procedure's code into the trigger. So far, so good... since triggers execute after the changes are made, the stored procedu...

SQL Server Check/NoCheck difference in generated scripts

I am trying to sync up the schemas between to different databases. Basically, I ran tasks->Generate Scripts with SQL Server Management Studio (2005) on both databases and am comparing the output with a diff tool. For some reason, one script adds the constraint WITH CHECK and one WITH NO CHECK, followed by both constraints being re-enab...

Cleaning Up Temporary SSRS Reports

Our application uses SQL Server Reporting Services and allows users to add custom filters to reports. We do this by modifying the RDL and then uploading the modified RDL to the server to create a new report. The problem is that after the report has run once, it's no longer needed; it's really just a temporary report. Obviously, this woul...

Good Strategy for Message Queuing?

Hi there, I'm currently designing an application which I will ultimately want to move to Windows Azure. In the short term, however, it will be running on a server which I will host myself. The application involves a number of separate web applications - some of these are essentially WCF services which receive data, and some are sites f...

Alternatives to SMO, i.e. DML APIs for SQL Server?

I just learned I can't use SMO in ASP.NET without either SQL or a full SMO install on the application server. I'm not allowed to do that, so I can't use SMO. What other libraries do the same thing as SMO but don't require an MSI installer or COM registrations? I know I could send DDL to the server inside ADO.NET commands, but that is ...

Get the maximum of 2 columns in SQL Server

If i have a sql table with column like this id version subversion 1 1 0 1 1 2 1 2 0 1 2 1 I want to get the latest version, in this case is 2.1. What should I do? ...

How to return only rows that are inner-join'd more than once

I have two tables, one for invoices and one for incoming payments. An incoming payment can be joined to an invoice by a foreign key like so: from invoices t1 inner join incoming_payments t2 on t1.receiptnum = t2.docnum The question: I want to return all invoices which have more than one payment posted against them. For each invoice...

Accessing SQL Report Web Services

Hi, I am testing an app locally that is built in coldfusion. I have sql report services running and i would like to access reports using cold fusion. I can only access web services through IE. How can i enable anonymous access to the server so that i could do a simple http request from within coldfusion to grab the report. Secondly, i...

To get digits after / in stored procedure

hi guys, I have a field in table.Suppose its value is 2009/1234.I want to get digits before'/'.I want to do this in stored procedure in sql.Can anybody help? ...

SQL database differences.

Hi all, I have there 2 codes on how to connect to SQL Server 2005 database. code 1 are using Dataset, and Dataadapter, code 2, didn't used neither. Can anyone please help me explain what is the differences and advatages/disadvantages on both programs..thankz code1 //create connection, dataset, dataadapter System.Data.SqlClient.SqlCon...

inserting into a view in SQL server

I have a SQL Server as backend and use ms access as frontend. I have two tables (persons and managers), manager is derived from persons (a 1:1 relation), thus i created a view managersFull which is basically a: SELECT * FROM `managers` `m` INNER JOIN `persons` `p` ON `m`.`id` = `p`.`id` id in persons is autoincremen...

SQL, How to Concatenate results?

I currently have a SQL query that returns a number of fields. I need one f the fields to be effectively a sub query sub that. The Problem in detail: If I have a table X with two columns, ModuleID and say ModuleValue, how can I write a SQL query to take the results and Concatenate it into one field: EG Results returned from (SE...