sql-server-2008

Pros & Cons of TRUNCATE vs DELETE FROM

Hey everyone, Could someone give me a quick overview of the pros and cons of using the following two statements: TRUNCATE TABLE dbo.MyTable vs DELETE FROM dbo.MyTable It seems like they both do the same thing when all is said and done; but are there must be differences between the two. Thanks again! ...

Easy way to search SQL Procedures?

I'm a new developer trying to add new functionality to an old project. The new code I'm trying to implement involves database tables, so I'm looking for the procedure that is called to update or originally populate the table. But there's over 50 procedures. Short of opening every procedure manually and using CTRL+F to search for the te...

TSQL Merge statement hanging

I currently run the following statement and the query never completes. I am unsure why as I use the same query with other source tables and it completes very quickly, this source table is not bigger. merge into dbo.Tickets_Amends as target using dbo.Tickets_Healthchecks_parentlesstickets as source on (target.fault_ID = source.fa...

Detecting if SQL Server 2008 is installed

I am using dotNetInstaller as a bootstrapper and I need to detect if SQL Server 2008 or above is installed as a prerequisite. Currently I am using this registry to detect the installation: HKLM\SOFTWARE\Microsoft\Microsoft SQL Server 2008 Redist\SharedManagementObjects\1033\CurrentVersion\Version If the value of Version is 10.0.0 or h...

sql where clause in select statement issue

Hello everyone, I am using SQL Server 2008 Enterprise with Windows Server 2008 Enterprise. I have a database table called "Book", which has many columns and three columns are important in this question, they are Author, varchar; Country, varchar; Domain, varchar. I want to write a store procedure with the following logics, but I do ...

how can i distribute the future data onto separate computers using ms sql srvr08.

i have made a one database having three tables. these three tables are common across 20 departments in a college, but the data is not. problem is each department has its own computer lab, and wants to maintain its own computer where only the particular departments data is stored. ( please ignore the fact that its not needed as sql ser...

Using SQL 2008 ServiceBroker for high-volume threadsafe FIFO queue

I'm just starting to evaluate ServiceBroker to determine if it can perform as a reliable queue in a very specific context. Here is the scenario: (1) need to pre-calculate a large (several million) population of computationally expensive values and store in a queue. (2) multiple processes will attempt to read/dequeue these values at ru...

What happens to system agent tables on SQL Server Restart?

What happens to the system agent tables whenever the database server is restarted? More specifically, does SQL Server assign new job_ids to each job when they are run after the reset, or does the job_id stay the same? ...

Using XML as a SQL Parameter to load multiple objects

Hey everyone, I'm a newbie at this, so bear with me for a second. I have a dictionary like so: var dict = new Dictionary<int, SalesStatistics>(); SalesStatistics is a custom class; that contains various information about products. The key field holds the ProductId. I need to iterate across this dictionary, and for each ProductId i...

SQL Server - Copy stored procedure's from one database to other

I am trying to copy a database with huge data from SQL Server 2005 to SQL Server 2008. I tried using the Copy Database Wizard but could not use the wizard because they are two different server 2005 and 2008. So I copied all the tables using Import data wizard from SQL Server 2008. I had about 1120 stored procedures to be copied, so on ...

Dynamic SQL Query (variable entries, and variable entries per column)

Sorry for the long post, but most of it is code spelling out my scenario: I'm trying to execute a dynamic query (hopefully through a stored proceedure) to retrieve results based on a variable number of inputs. If I had a table: (dbo).(People) ID Name Age 1 Joe 28 2 Bob 32 3 Alan 26 4 Joe 27 I want to allo...

Provider and subscriber in SQL Server 2008, can subscriber handle insert/delete?

Assuming I did all that is needed (consider complete replication) Make server "A" the provider and server "B" the subscriber Question: If I want to add, delete, update, or insert data, will I be able to do that by connecting to the subscriber? If yes, will the data change be automatically reflected in the provider? Using: C#, ASP....

Is there a quick way to determine what tables are referencing a specific primary key as a foreign key?

I'm doing a small bit of refactoring, however, I'd like to check to see if the current primary key I'd like to change is currently being referenced as a foreign key in any other tables. The schema I'm working with is quite large so it is not a viable option to scan through each table in the schema. ...

SQL Server Difference (opposite of intersect)

Looking for the easist/most scalable way to do a set "difference" in SQL Server see below. If you can't tell from the picture i am looking for everything that is not in the intersection. I have seen one way to do it: select * from ( (select 'test1' as a, 1 as b) union all (select 'test2' as a , 2 as b union all select ...

inserting a node into SQL 2008 xml datatype... checking if it exists first

Hi, I am reading through a plethora of articles at the moment to try to assist me.. just seems so many options and cannot seem to find a clean solution.. it probably is very basic so apologies in advance! So I have an XML field in SQL 2008. It basically contains something like: <root><id>1</id><id>4</id></root> and so on... What I ...

update in data flow with validation

Hi All, I have a case of updating the target table where source columns data not equal to target columns data. I am trying to do this in data flow OLE DB command component but not supporting multiple usage of the columns. I don't want to use the MERGE statement due to the database hits in this business logic. UPDATE targettable set co...

SQL Server 2008 - Query execute => timeout on my webservice - web application

When i execute a query on my SQL Server (same database as my web application) and my query gets a timeout, all my web users on my web application also receive a timeout. Is it possible to avoid this problem? ...

get the hours for every month

Hi Guys, I have created a function which will take two parameters as startdate, enddate and returns hours from that. here i am getting both the total hours but i need to get individual month hours from that. Regards, kumar ...

how to start SQL Server 2008 service from command prompt?

i want to start the Microsoft SQL Server 2008 services from command prompt. how can i achieve through command prompt? ...

SQL Server 2008 SP1 takes a long time to restore database

Hi all, I'm using SQL Server 2008 SP1. It takes a long time when restoring the database from backup file. Following the Microsoft support website (http://support.microsoft.com/kb/975089) that was a bug of SQL Server 2005 & 2008 and they released a update package which named "Cumulative update package 5 for SQL Server 2008 Service Pack 1...