sql-server-2005

SQL Server 2005 - Rows to Cols

I have a table CSFT_SuggestionItem with cols like: SuggestionItemID Title Description, etc. ------------------------------------------------------------ 1 Item 1 Do more work 2 Item 2 I think more is good For each SuggestionItem, there can by multiple "Applic...

Control store procedure outputs

I have the following store proc SET @sql = 'RESTORE DATABASE ' + quotename(@dbname) + ' FROM DISK = N''E:\sql\template_' + @dbnamebak + '.bak'' WITH FILE = 1, MOVE N''FromTemplate' + @dbname + '.Data'' TO N''E:\sql\' + @dbname + '.mdf'', MOVE N''FromTemplate' + @dbname + '.Log'' TO N''E:...

Crosstab/Pivot query in TSQL on nvarchar columns

I have a Table1: ID Property 1 Name 2 City 3 Designation and Table2: ID RecordID Table1ID Value 1 1 1 David 2 1 2 Tokyo 3 2 1 Scott 4 2 3 Manager The Table1ID of Table2 maps to Table1's ID. Now I wish to show the Table1 Property column values as colum...

Data difference between two database

Hi All, I am working on SQL Server 2005. I have took the backup and restore the database. I just wanted to know is there any way I can check whether the data between these two database are diffent. or any script that I can run or check [ could be table by table] to see if any new row added or modified. EDITED For example - I have to c...

query with string manipulations

I need a query for the following problem. Table1 specifies the mandatory input fields. I will fetch the fields with inactive = 'No' and mandt field = 'yes' So i have 4 records with fields as sev,sev1,cde,frt. Table1: Fields Inactive mandt_field sev no yes sev1 ...

T-SQL 2005: combine multiple create/alter procedure calls in one transaction

Hi all, I want to build a T-SQL change script that rolls out database changes from dev to test to production. I've split the script into three parts: DDL statements changes for stored procedures (create and alter procedure) data creation and modification I want all of the changes in those three scripts to be made in a transaction. E...

placing the json data to sql database from webservice

This is the particular webservice code where i retrieve the username ,how i can i write c# code to place json data to sql database in webservice and display the acknowledgement in html page public class AjaxService : System.Web.Services.WebService { [WebMethod] public bool CheckUserNameAvailability(string userName) { ...

Linq2Sql not updating NVarchar(Max) field?

I have the folowing code to fetch a record and update one column which is of type NVarchar(Max) using Linq2Sql. using (var context = new DataClasses1DataContext()) { var entity = context.Entity.Where(d => d.ID == 12).Single(); entity.EmailTemplate = "Test Template"; context.Sub...

How to track & store email replies?

Currently on our system, when a user contacts us, we reply via our admin panel. The user is then sent an email containing our message and the other messages in the conversation. Then the user has to click on 'Reply to this message' which opens up our website, with a contact enquiry form, and submits the message to the conversation (usin...

determining histogram bin size

I'm looking to create a histogram in SQL (which in itself isn't too tricky), but what I'm looking for is a way of splitting the bins so that each bin / band has the same proportion of the data included within. For example if I have the sample data (the value column) and I want to divide it into 5 bins, I know that I can work out the num...

How to Delete data from a table which contain self referencing foreign key

This is for a MS SQL 2005 server. I have a query that is deleting all orphaned records in a table. However, this table has self-referencing FKs. I need to delete these as well, but am unclear how to do so. The current script deletes all records that not appear as FKs in other tables, but i didn't take into account the self-referencing...

Good SQL 2000 to 2005 SQL Cleanup tool

Hello, My company is doing an upgrade from 2000 to 2005 and we are taking the oppurtunity to cleanup some of the report queries. One I did today went from 10 minutes to 1:30 fresh and then 2 seconds once SQL has the execution plans. Anyway, what I was looking at the execution plan trying to find more places to cleanup and I noticed a ...

Creating tables in SQL Server 2005 master DB

I am adding a monitoring script to check the size of my DB files so I can deliver a weekly report which shows each files size and how much it grew over the last week. In order to get the growth, I was simply going to log a record into a table each week with each DB's size, then compare to the previous week's results. The only trick is ...

SQL Server/CF 3 - Merge Replication: Fails using Replication.SaveProperties when changing Subscription Info

I'm trying to use SQL Server/Compact Framework 3 Merge Replication functionality and am running into a problem when calling Replication.SaveProperties (using c#). I was hoping to get some clarification on whether its my interpretation on how things should work vs a coding problem. Basically, the Merge Replication seems to work as I can ...

SQL Set variable with single column in select field

I have a column along with many others that returns a int value. It is the same int value for every record in this column. If this value is 1 I need to set a variable = 1 if it is 0 i want the variable to be 0. How do I go about doing this? There can only be a 0 or 1 in that column. And again it is the same throughout the entire column...

Suggested replication type?

I have 2 similar tables in different servers, data in certain columns can only be changed by server A while data in other columns can only be changed by server B. However, I need these tables to always be consistent (1 minute schedule). Is this the kind of scenario that "Transactional replication with updatable subscriptions" solves? ...

Query with no autosort

Possible Duplicates: Ordering MySQL results by IN sequence? Ordering by the order of values in a SQL IN() clause i have the following table called "Products" id desc 1 BL10 2 BL15 3 BL45 4 BL50 well, this is my query SELECT * FROM Products WHERE id IN(3,1,4,2) I want it shows in the same order of clause IN, i.e. 3,1,4...

Can you add a Text box to a report in SSRS that links to an email?

Is there a way to add a text box or button of some kind in a SSRS report where the user clicks it and then it opens an email account for the user to enter any bugs found? Thanks much for your help. Moni ...

Can't connect to server in SQL Server 2005

I am using Sql Server 2005. When the connect to dialog box opens, it asks me for the server name. I entered "localhost", but I am not able to connect to the server. An error message is displayed. How can I connect to server and where can I find the server name? ...

set column to insert extat charachter in Sql Server

Hi I want to insert char (A) in second index where code start with 's' Input s1 s2 s34 Require output sA1 sA2 sA34 Update T1 set code = ?? where code like 's%' ...