sql-server-2005

how to update all clients after each db transcation

I am developing a Client-Server based app using WPF, SQL-Server and WCF. This is basically a kind of POS application (not using any POS library but features are almost same). Server side coding is almost done. Now I am moving to client side coding. I am new in WCF (first app on WCF) and Client-Server architecture, so I surrounded by so...

Getting the local instance of SQL Server rather than a named instance

Hi! A while ago, I wrote a web-based guestbook application that wrote it's own database. My code was very amateurish, but, as it was my very first publication, I was very happy with it. Only about a month after I'd published it did I realize I'd made a huge mistake in the code. I've only ever connected to a specific named instance of ...

SQL Server 2005 - Find Which Stored Procs Run To A Particular Table

Is there a quick way that I can find which stored procedures run to a particular table in my database? The database is very large with lots of tables and SPROCS.... ...

Automatically create scripts for all SQL Server Jobs

Currently I'm trying to automatically generate a create script for all my SQL jobs of a MS SQL2005 Server. One method I found was done manually http://msdn.microsoft.com/en-us/library/ms191450.aspx A second method I found could be done automatically but I don't have direct access to the SQL server. http://relatedterms.com/thread/19166...

Is database is in backup mode ?

Is there any way to find whether the database is in backup mode or not. Is any sys tables can provided this informtion. ...

SQL Server Date Selection

Update How to write query on sql server to check case IsValidDate(Date) then Date+ ' days ' worked when IsEmptyorNUll(Date) then '*' ...

SQl Server 2005: Rows to columns -- how to do this challenge?

Please let me know, How to convert the following data , [id] cost1 cost2 year 1 5 10 2010 1 4 15 2011 2 10 10 2010 into this format [rows of 'Year' to columns heading] id [cost1-2010] [cost2-2010] [cost1-2011] [cost2-2011] 1 5 10 4 15 2 ...

How compare weekly load records using ssis

how to compare data in a table after a weekly load has taken place using ssis table Create table Host CPU memory Hostname varchar(120) not null Datetime datatime notnull CPU float notnull memory float notnull start_date datetime notnull (load of the file) End_date datetime notnull (High date) - 31/12/9999 In the above table there is a...

changing the primary key value in SQL server 2005

I have a Table which has a Primary Key field which is not set to auto-increment. I want to change one of these primary keys to something different. The problem arises with the other tables relations. The thing is, the guy who built this system did not build relations in SQL Server, but rather manually coded some override in the program ...

Procedure resuming even after the error

Below is my procedure in SQL Server 2005 PROCEDURE [dbo].[sp_ProjectBackup_Insert] @prj_id bigint AS BEGIN DECLARE @MSG varchar(200) DECLARE @TranName varchar(200) DECLARE @return_value int -- 1. Starting the transaction begin transaction @TranName -- 2. Insert the records SET IDENTITY_I...

How can I insert a set of child records while updating the parent?

I'm using SQL 2005 and wish to create a number address records, updating the contact records with the new Id's: Take the following tables create table contact(id int primary key identity, home_address_id int, work_address_id int) create table address(id int primary key identity, street varchar(25), number int) And foreign keys: ALT...

How to drop and recreate and primary key index using SMO with SQL Server?

I am using SQL Server 2005 Express. I want to use SMO to loop through each table in a database and change each Char column to a Varchar column. If a column is a member of the primary key, I need to first drop the primary key before altering the datatype of the column. Then I need to recreate the index. Here is the code I am trying to...

SQL: BETWEEN and IN (which is faster)

Possible Duplicate: Is there a performance difference between BETWEEN and IN with MySQL or in SQL in general? If I have the following ids: 1,2,3,4,5,6 Is it better to use IN or the between clause for deleting? ...

Creating a database sandbox/testing area for users to run what-if scenarios

I'm trying to figure out how to create a "sandbox" area in my new Windows .NET/SQL Server application. Here's the requirements: Users must be able to enter their own data for things like date ranges and pricing Users must be able to run multiple scenarios against this pricing and date range data The data structures above will also be u...

how to create utility stored procedure and run it like other sp_... utilities

I need to create a stored procedure one time and in one place only on my database server, but be able to run it from any database. However, I don't want to have to type database.schema.procedure_name every time I run it. I'd like to be able to use it like the built in procedures: sp_... is there any way to do this? here is the proced...

Getting around cached plans in SQL Server 2005

Can someone please explain why this works. Here is the scenerio. I have a stored proc and it starts to run slow. Then I pick a parameter and declare a variable to house its value and in the proc use the declared variable instead of the parameter. The proc will then speed up considerably. I think it has something to do with the cache...

Creating new date field dynamically from next row

I have a table of data. I have a field which shows date. I had set this column as Start Date. I want to create an additional column as End Date, where the End Date will be the Start Date of the next row. Can you give me a query of creating the End Date by taking the data of the Start Date in next row ? ...

Add empty row to query results if no results found

I'm writing stored procs that are being called by a legacy system. One of the constraints of the legacy system is that there must be at least one row in the single result set returned from the stored proc. The standard is to return a zero in the first column (yes, I know!). The obvious way to achieve this is create a temp table, put the...

How can I select tags from an SQL XML Query?

How can I retrieve the fields within an XML field in MS SQL? Every query I try does not work as intended whenever I use this XML code: I want to select the AccNumber value. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSch...

display the top 3 records in a comma separated in one column

Hi, I came into problem that I need to display the top 3 records for each aId in a comma separated string in one column (for eg. aId=151 ghghg,ghh, rgtg ) instead of the below result. Can anyone help me please? Expertise ghghg ghh rgtg rtrt ghgh tyuyu fgfg yuu dfdf gtyy dfdf df ssd dfd dfdf fd dfdf d...