sql-server-2005

Suggestion for a tag cloud algorithm

Hi, I have a MSSQL 2005 table: [Companies]( [CompanyID] [int] IDENTITY(1,1) NOT NULL, [Title] [nvarchar](128), [Description] [nvarchar](256), [Keywords] [nvarchar](256) ) I want to generate a tag cloud for this companies. But I've saved all keywords in one column separated by commas. Any suggestions for how to generate...

PROBLEM EXECUTING a query in vb

I have a problem with a sql query. Through the query I am trying to search database for any occurrences of string (can be anything) in a column using the SQL LIKE command. The problem is that it works fine for most of the strings say john, jim, ji"m , but does not work when i include the following characters which are ( ' , { , } , and a...

How do I create a third table from two tables?

I have two great tables that I would like to use as foundation for an even greater third table! The output depends on date interval, like 09/01/2010 - 09/03/2010 Example of Output from TABLE A - - (ALLOCATED Testers) Date Country Allocated testers 09/01/2010 Nigeria 0 09/02/2010 Nigeria ...

How do I "Declare the scalar variable" in a VIEW in Sql Server (2005)

I´m trying to create a VIEW in SQL Server 2005. The SQL code is working as such (I´m using it in VS2008), but in SQL Server I´m unable to save it, as error message "Declare the scalar variable @StartDate" and "Declare the scalar variable @EndDate" pops up. Here is the code: WITH Calendar AS (SELECT CAST(@StartDate AS datetime) AS ...

Selectively Update fields

I have a stored procedure that is required to update an existing record with new data, however it must not 'over write' any existing data. For Example we may have three fields: FirstName | LastName | PhoneNumber Call the above 'TableX'. In a very simple update this could look something like this: Update TableX set FirstName =...

How to delete row if the previous have the same value in specific a column

Let's say I have a table that looks something like this: ------------------------------- id|column2|column3 |column4 ------------------------------- 1 value1 somevalue somevalue 2 value2 somevalue somevalue 3 value2 somevalue somevalue <----- I want this column deleted 4 value3 somevalue somevalue As you can see I want t...

User synchronization in WCF web service performing database operations.

Hi, I am new to wcf and I have written a wcf web service that performs operations on database like an update. The service is consumed by silverlight clients. When multiple users try to make certain change to an object, I want the wcf service to manage it. e.g. if a certain object is acknowledged(update operation in db) by one user, anoth...

SQL Server: Login failed (for win user, instead the specified one)

Hi all, While connecting to a remote SQL Server 2005 from my C# code I get a login error (Login failed for user X) This 'user X' appears to be the windows user, instead of the one I specified in my connection string, that was a SQL Server user. Anyone knows the problem here? The server is in another machine, and I cannot make changes o...

SSIS error information

I have 15-20 data task each in their own sequence container in a single SSIS. Is it possible to catch the data task or sequence which failed and email that details (task name or sequence name, cause for failure) to a user? ...

Sqlcommand Parameters not executing

I am encountering a strange problem when attempting to execute a DELETE query agains a SQL Server table using VB.NET, SQL Command, and Parameters. I have the following code: Try sqlCommand.Transaction = transaction1 sqlCommand.Connection = conn sqlCommand.CommandText = sqlQuery sqlCommand.Parameters.Add("@userID", S...

Calling Linked Server Stored Proc and retrive OUTPUT Parameters?

I have Linked Server to Oracle in SQL Server 2005. There 2 Stored Procs defined. How can I call them in SQL server. One Stored Proc has two OUTPUT parameters. I need to get them in SQL server call Linked server name is TEST. below are stored procs. I need these SPs separately. check_lockout(v_id_in, v_out_result, v_lockout_msg); upda...

SQL Server XmlType not preserving the CDATA element...

We are using SQL Server 2005 and are trying to store an XML Type in the database. The XML type has an element that needs to contain the content in CDATA, yet once inserted, the field seems to be stripping the CDATA and storing the element without it... Has anybody experienced or even resolved this in the past? Handy example: create t...

Merge two field into One with only new items

I have two tables which both contain 'pipe separated values' e.g: Table 1: DataField_A item 1|item 2|item 3|etc..... Table 2: DataField_A item 7|item 5|item 3|etc..... I need to merge Table 2 into table 1 such that Table 2 contains all items across both tables. Doing this pro-grammatically would be a simple matter of loop...

Using DISTINCT on a single column of a multi-column select gets correct results but can get it to order by createon date?

Please review the following query and see if you can help me out. DECLARE @Contacts TABLE ( workgroupid UNIQUEIDENTIFIER, contactid UNIQUEIDENTIFIER, leadname NVARCHAR(130), createdon DATETIME, Marketsource NVARCHAR(150)) INSERT INTO @Contacts (workgroupid, contactid, leadname,...

User is not associated with a trusted sql server connection - non-domain computer

I'm trying to connect using several different clients to SQL Server 2005 standard, which has been configured to use Windows Authentication. Although the user account exists on the domain, the computer is not joined to the domain. I get the message, "user is not associated with a trusted sql server connection". The question http://stac...

SQL Conditional JOIN

I have three tables 'Employees', 'Departments' and 'EmployeesInDepartments' The 'Employees' tables references the 'Departments' table (Each employee must have a DepartmentId). However, an employee can exist in multiple departments by adding entries (EmployeeId and DepartmentId) to 'EmployeeInDepartments' table. I currently have the foll...

SQL Server takes forever to process when I use a local variable instead of specifying a date directly?

I apologize in advance for my newbness! Using SQL Server 2005 (9.00.4053.00). It takes 2:22 to run this query: DECLARE @Start_date CHAR(10); SET @Start_date = '2010-07-01'; SELECT DATEPART(wk, rp.dtScanDate) AS 'Week Number', COUNT(rp.qwImageID) AS 'Documents', SUM(CAST(rp.iCompressedSize AS BIGINT))/1024/1024 AS 'Compr...

Unable to step into stored procedure inside stored procedure - SQL debugging using VS2010 and SQL Server

I'm checking out the SQL Debugger using Visual Studio 2010 (connecting to a SQL 2005 Enterprise Server), and I can successfully debug a stored procedure by going to Server Explorer -> Right clicking on the procedure -> "Step Into Stored Procedure". However, once I'm in, I can't step into or set any breakpoints inside any subsequent func...

Generate XML-formatted table schema from SQL Server 2005?

Hi everyone, I was wondering how I might take a table schema in SQL Server and generate an XML document from it. The ideal would be if I passed in my database name (“SalesOrders”) and an XML doc comes back reading something like: <table=”SalesOrders”> <columns> <name=”SalesOrderID”/> <datatype=”int”/> <allowNulls=”...

Changing local clock affects remote SQL Server database functionality

Hi all, I'm having an issue with some SQL Server 2008 queries and I think I got it down to differences between the server and the local application. Here's a basic description of my scenario: I'm using a local application that performs insert statements on a remote database. Everything works fine until I change the clock on the local m...