sql-server-2008

MDF file size much larger than actual data

For some reason my MDF file is 154gigs, however, I only loaded 7 gigs worth of data from flat files. Why is the MDF file so much larger than the actual source data? More info: Only a few tables with ~25 million rows. No large varchar fields (biggest is 300, most are less than varchar(50). Not very wide tables < 20 columns. Also, no...

transfer subscription reporting service

Hi, Would you recommend the best and easy way to transfer (or copy) the subscriptions from one reporting service to another reporting service in different server? ...

export multiple (same) dbs and import into one automatically

I need to write a program or script which a client can run to do the following. I have an application which runs offline on multiple computers which is exactly the same but the data will differ. Let's call this SourceDB. Therefore, there is SourceDB1, SourceDB2, and SourceDB3. Then there is a server which hosts the main application whic...

SELECT FOR XML, How to use?

This statement below: SELECT .... FROM .... WHERE .... FOR XML PATH('Booking'), ROOT('doc') This returns all the records in one XML string. I wish for each record to have its own XML string. Does this make sense? Is it possible. Does it make sense to do this? I am using Microsoft SQL Server 2008 ...

backup database in schedule or not how to find through t-sql

Through SINGLE T-sql query can we find : 1. Database Backup mode - [full,simple,bulk] 2. IS database is scheduled for backup [yes, no] 3. If backup is enabled the size of the DB backup and Daily transaction log backup size ? any help ...

How to convert an ESRI Shape-file into SQL Server 2008?

I have a shapefile that I would like to upload to a spatial SQL Server 2008. I have tried using this tool: SQL Server 2008 Spatial Tools. But without luck. Does anyone know any other (free) tools for doing this? ...

Make It Look Like You Are Typing A Text In A Command Prompt

I am looking for a way to show a random nvarchar field from a SQL Server 2008 database in my Visual Studio 2008 ASP.NET web project. but there is one condition: I want the text to look like you are typing it in a command prompt. Is marquee my solution? Can you show me an example of binding from database & command prompt typing? ...

How to test performance for your database Best practice

Hi, I need to test indexes performances for some table in my database. After I run my query with indexes or without them I always use this code; SELECT * FROM sys.dm_exec_query_optimizer_info; And I receive details about my query. My problem is: using sys.dm_exec_query_optimizer The details for my query are always changing making...

Transact-SQL / Check if a name already exists

Simple question here. Context: A Transact-SQL table with an int primary key, and a name that also must be unqiue (even though it's not a primary key). Let's say: TableID INT, TableName NVARCHAR(50) I'm adding a new rows to this able through a stored procedure (and, thus, specifying TableName with a parameter). Question: What's the b...

SQL Functions - factorial

I am a beginner in SQL Functions. What is the best way to create a function for factorial in SQL Server- Say 10! ...

Select all row for specific column query SQL Server 2008

i want to know what is the wrong in this query I want to select all rows for 1 column string command = "select money from User_Data"; SqlCommand update_money = new SqlCommand(command, con_string.con); SqlDataReader money_reader; money_reader = update_money.ExecuteReader(); ...

SQL Server 2008 Filestream Logon Failure: unknown user name or bad password

When using(attempting) the SqlFileStream object, I am receiving an error System.ComponentModel.Win32Exception: Logon failure: unknown user name or bad password I'm a little perplexed by this. I'm using SQL Server authentication in the connection string I can write to the table in question except for the FILESTREAM column The SQLSE...

Fastest technique to deleting duplicate data

After searching stackoverflow.com I found several questions asking how to remove duplicates, but none of them addressed speed. In my case I have a table with 10 columns that contains 5 million exact row duplicates. In addition, I have at least a million other rows with duplicates in 9 of the 10 columns. My current technique is taking ...

Inserting numerous incremental values in a column

Got a table with 1200 rows. Added a new column which will contain incremental values - Candidate1 Candidate2 Candidate3 . . . Candidate1200 What is the best way to insert these values , non manual way. I am using SQL Server 2008 ...

Passing XML to Procedures

I just switched groups and what they currently do is have their middle tier pass XML to the procedures and then use xquery/xpath to parse the xml and use it to get information and return it back to the app (RETURN XML). I was just curious if others use a similar process or if they just pass the data directly into the procedures. I reall...

Updating parent property values in SQL

Hello, I have a SQL Server 2008 database with 2 tables. These tables are defined like this: Device ------ ID Name Description TotalApplications Application ----------- ID Name DeviceID I recently added the "TotalApplications" column in an effort to speed up a query that is taking WAY too long. The number of applications associated w...

SQL Server 2008: Collation ignored in unique index?

I've created a compound unique index on my table: CREATE TABLE [dbo].[SearchIndexWord]( [ID] [int] IDENTITY(1,1) NOT NULL, [CatalogID] [int] NOT NULL, [Word] [nvarchar](100) NOT NULL, CONSTRAINT [PK_SearchIndexWord] PRIMARY KEY CLUSTERED ( [ID] ASC ) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY...

Index comparison between SQL Server

I have to write a sql script for comparing the difference's with the indexes of table of SQL Server. ...

Why doesn't EF 4 generate association for FK relation to column with unique index?

Hi all, I have run into a scenario where Entity Framework 4.0 does not generate an association to an entity backed by a table having a unique index, and I am wondering why. The basic setup is this: Let's say I have two tables in SQL Server 2008 R2 and a foreign key relation: CREATE TABLE [dbo].[User]( [Id] [int] IDENTITY(1,1) NO...

Concurrency issue in SQL server 2008

I have 2 tables- master and detail table. Master Table has ID column which is Primary key and Auto Id. I have wrtten an SP to insert records into both tables. In this SP, when a record id inserted in master table, current_ident is fetched and stored in a variable which is then passed to detail table insert the detail records. This is wo...