sql-server

Configuration for SQL Server Based Assembly

I have an assembly deployed to SQL Server that performs an export to an accounting system SDK. The reasons that this is deployed to SQL Server are beyond my control, and I cannot modify the target database. In development, I moved several dynamic queries from hard-coding to text files outside the application, so that queries can be twe...

How come the message "Table is marked for deletion" keeps appearing?

Using SQL Server 2008 and I'm doing some schema construction in the Management Studio designer. I created a table early in the process called "Animal", but then decided to delete shortly after. I deleted it via the tree view in Management Studio (right-click delete). Now I'm late in the process, I would like to recreate the table "Anim...

SQLServer: How To bind fixed values to Column?

Say I defined a char column Type. I want to strict its value to say for example (Black, White, Red, Blue) Only... How can I do that?? All i know, this is easy in Access :P ...

What’s the best way to bulk database inserts from c#

How do I/what’s the best way to bulk database inserts? From a c# perspective I am iterating over a collection and calling an insert stored procedure for each item in the collection. How do I send all the data in one database call? E.g. say I have a person list (List) containing 10 items, I am currently calling the InsertPerson store ...

Including a named instance of SQL Server 2008 Express with my application

Good morning, all. This is my first question on stackoverflow, so hopefully this isn't something that's been beaten to death and I haven't been able to find it. I'm developing an application that is going to be distributed shrinkwrapped. We have gotten the rights to distribute SQL Server 2008 Express Edition with our application, but ex...

Printing ServerReport without Preview

I have a SQLServer 2005 Reporting Services ServerReport deployed and frequently used by my Winforms app (Framework 2.0) via the ReportViewer control. What I need is to provide a one-click print button from one of the forms of the app that triggers only the print dialog, without bringing up the ReportViewer. I've been experimenting wit...

How to separate automatically populated tables from manually populated tables, properly, in SQL Server?

Lets say I have the following 2 tables in a database: [Movies] (Scheme: Automatic) ---------------------------- MovieID Name [Comments] (Scheme: Manual) ---------------------------- CommentID MovieID Text The "Movies" table gets updated by a service every 10 minutes and the "Comments" table gets updated manually by the users of the d...

Sql Server Ce 3.5 Identity insert

hi there got an issue with identity columns in Sql Server CE when using Server explorer, in VS2008, executing the following script SET IDENTITY_INSERT testTable ON; Insert into testTable (id,name) values (1,'Something') SET IDENTITY_INSERT testTable ON; sends the follow message error 'The Set SQL construct or statement is not supporte...

What's the best way to perform math on a floored date in SQL Server?

This is related to Floor a date in SQL server, but I'm taking it one step further: I'm writing a query on a SQL Server table and I want to get all records for the current calendar year and the previous calendar year. So, right now, I'd want a query to return all records between January 1st, 2008 and today. But come January 1st, 2010, I ...

SQL language differences between MSSQL 2000 and 2005

My company has an application developed for SQL Server 2005 (among others), and a potential client is attempting to install it on SQL Server 2000. Naturally, installation failed. Specifically, it failed with syntax errors in our CREATE TABLE statements. Is there a summary of the language differences between these two databases? ...

How do I 'refactor' SQL Queries?

I have several MS Access queries (in views and stored procedures) that I am converting to SQL Server 2000 (T-SQL). Due to Access's limitations regarding sub-queries, and or the limitations of the original developer, many views have been created that function only as sub-queries for other views. I don't have a clear business requirement...

Where can I find a good comparison between SQL server and Oracle?

Where can I find a good comparison between SQL server and Oracle? (Note the original question referred to "...types...function...". Perhaps the original asker could clarify what was meant.) ...

How to insert sequential numbers in primary key using select subquery?

I am reading a table A and inserting the date in Table B (both tables are of same structure except primary key data type). In Table B, Primary key is int whereas in Table A it is UniqueIdentifier. INSERT INTO TableB (ID, Names, Address) (select ID, Names, Address from TableA) Now how can i insert int type incremental value (1,2,3,so o...

When were stored procedures introduced into the SQL Server product?

Here's a bit of a different question for you computer history buffs. Help me settle a bet between myself and a buddy of mine: Q: When were stored procedures introduced into the SQL Server product? I need the year and/or version. Thanks. EDIT: Ok, going back beyond SQL Server to Sybase ...

Find the smallest unused number in MS SQL

How do you find the smallest unused number in a MS SQL column? I am about to import a large number of manually recorded records from Excel into a MS SQL table. They all have a numeric ID (called document number), but they weren't assigned sequentially for reasons that no longer apply, meaning from now on when my web site records a new ...

SQL Server: Script all DB objects (SP, Tables, Triggers, etc.) to SQL script.

Hi, I would like to ask the experts here on how to script the database objects in SQL Server 2008 Express Edition. When generating scripts, I found out that only tables and triggers are available to be script. But how can the SPs be scripted too? The problem is that I have a host provider and I wanted the database in my site to have AS...

complex sql query - merge or replace groups

Im building a school website and got stuck on this problem. The SQL database is structured as follows ( i do not have permission to modify their database) **GroupRecords** Id (int, primary key) Name (nvarchar) SchoolYear (datetime) RecordDate (datetime) IsUpdate (bit) **People** Id (int, primary key) GroupRecordsId (int, foreign key t...

How to detect SQL Server Express in WiX installer

How do I detect if Sql Server Express is installed and running on a machine in a WiX installer? I want to check before installing my application and if it's not installed and running, to inform a user that it has to install it first before installing my application. ...

Is there a simple way reset a MSSQL 2005 database to a predefined state during debugging?

I often find myself in the following situation: The customer reports corrupt data in his database. We investige the problem, sometimes by try and error. We try to solve the problem by using our application or one or two repair tools we ship with our product. (Only in bad cases we write a repair script for individually addressing a spec...

What is best tool to compare two SQL Server databases (schema and data)?

I would like to compare two SQL Server databases including schema (table structure) and data in tables too. What is best tool to do this? ...