sql-server-2005

SQL Server 2005 and Datanucleus problem (ntext query)

Started getting errors with SQL Server 2005 This is the first time i've tested our app with Datanucleus 2.x (last test was made with DN 1.x) I use Eclipse RCP. Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The ntext data type cannot be selected as DISTINCT because it is not comparable. at com.microsoft.sqlserver.jdbc.SQL...

Update every column in every table

My database has recently been hacked by SQL injection leaving tags throughout data in all columns in all tables in my database. Is there a quick way of running a REPLACE UPDATE on all tables? Something like: UPDATE [all tables] SET [all columns]=REPLACE([all columns], '<script>....</script>', '') ...

SQL Server 2005

I created a table as emp_attendance in which I used some columns. Now I want to compare current date of system with current date of table means shows that record which are entered in same date. thank you. ...

Why are CTE's unable to use grouping and other clauses?

I recently learned about Recursive Common Table Expressions (CTE's) while looking for a way to build a certain view of some data. After taking a while to write out how the first iteration of my query would work, I turned it into a CTE to watch the whole thing play out. I was surprised to see that grouping didn't work, so I just replaced ...

Comparison operations on xs:boolean in SQL Server 2005

Can anyone explain to me the results of this query: declare @xml xml; set @xml = '<node attribute="true">Val</node>'; select T.c.query('xs:boolean(@attribute[1])') Value, T.c.query('xs:boolean(@attribute[1]) = false') ValueEqualsFalse, T.c.query('xs:boolean(@attribute[1]) = true') ValueEqualsTrue, T.c.query('xs:boolean(...

SQL Server: What is the best way to Data Migration?

Hi All, I want to migrate data from one database to another database in Microsoft SQL Server 2005. I need to verify those rows retrieved before I insert them to the destination database's tables. Which approach is reasonable for this kind of things? I am trying to use two datasets in my VB.NET program. Is it reasonable? Can you sugges...

query to select distinct

Hallo Friends, I need a query to throw an error message on comparison with table temp_invoice. It should compare the field [Task resp#] , against the [PB-ID] field in PB_Responsbility table for customer = 3D temp_invoice format Concession Number [Task resp#] TH-123 12345 TH-014 98065 TH-12...

Is the growth of a SqlServer database an intensive operation?

Hi, we have a Sql 2005 database and we have set the growth of the data file to autogrowth, 'By 1 MB' We see that it does that approx every 10 minutes (its 9 GB now). Is it as simple as: just put it to 10 or 100, or are there other things to consider, or can we just leave it at this because it's just an easy operation? ...

How to yield recursion in query? What is the use of "With" ? How it works internaly ?

Why this query is completed with error ? ;with tempData as ( select 32 as col1, char(32) as col2 union all select col1+1, char(col1+1) from tempData ) select * from tempData ...

Not using Where when Right side is null - problem with left join

I have a query: Select a.Col1,b.Col2 From a Left Join B b ON a.C = b.C Where b.D ='someValue' But when right side is null, I don't get record , so Left Join doesn't work. Do you know how to change this query to correct query ? ...

Cannot create a row of size 8937 which is greater than the allowable maximum of 8060

We are getting this error on a table in our database: "Cannot create a row of size 8937 which is greater than the allowable maximum of 8060." The table consists of about 400 varchar(max) fields. We are, however, only inserting empty strings into these fields. The insert seems to work, however when using SqlXml to read the data or whe...

How to write select query for this?

I have column COMPONENT_AMOUNT(money) ,MONTH_FOR(int), YEAR_FOR(int) and COMPONENT_TYPE(int). I want to find the sum of amount according to condition. I have written my query like this but it solve my purpose. My purpose is that if one select Nov-2010 then it will sum the amount up to this selected month including all the month of 2009....

problem when displaying images

I had aproblem in my new website I had published our company webite and there are page which retrieve products images from database it worked well but somtimes the images didnot diplay I check my code well and it well .So I couldnot fin the problem uptill now so please if any one face this problem please help me. ...

SQL select latest record revisions in one of three language supplied in order of preference.

So, I've got a table structure in SQL Server 2005 that has the following composite primary keys: Id int Culture char(5) (eg: en-US, en-GB etc...) Created datetime The User table has PrimaryCulture and SecondaryCulture columns representing the users language preferences. The Application table contains a single Culture column represent...

Why doesn't this specific syntax work for upserting?

Hello, I'm using SQL Server 2005 and I want to synchronize two tables which have the same definition but exist in different databases. MERGE INTO only exists in 2008 and I'd prefer a syntax where I don't have to specify columns in the UPDATE. So I stumbled upon various posts using the following syntax: UPDATE Destination FROM (Source I...

Sql - Question on Cursors and variables

I am trying to use a cursor to move create a column that has all parts equal to a field that was before it. In example | column1 | column 2 | | 1 | a | | 2 | b | | 3 | c | would to go... | column1 | column2 | column3 | | 1 | a | b | | 2 | ...

How to write a cross tab query with median

Here's my table ST NUM 1 1 1 2 1 2 2 1 2 2 2 2 3 2 3 8 I want to return a query where it returns the median of NUM for each ST ST NUM 1 2 2 2 3 5 I already have a median function SELECT CONVERT(DECIMAL(10,2), ( (CONVERT (DECIMAL(10,2), (SELECT MAX(num) FROM (SELECT TOP 50 PERCENT num FROM dbo.t ORDER BY num ASC) AS H1) + (SELECT M...

how to place images into sql server 2005

I have written the following code to place the image path into sql server 2005 but its not working is their any alternate way to place images into sql server from clientside application. example.html <form id="addresslistingform"> <fieldset id="fieldset1"><legend>Address for listing</legend> Zipcode:<...

I Need to Discard Days of Month and Make Duplicate Months as Distinct

SELECT e.firstName,t.setDate, w.wageAmount FROM TimeSheet t INNER JOIN Employee e ON e.employeeID = t.employeeID INNER JOIN Salary s ON s.salaryID = t.salaryID INNER JOIN Wage w ON w.wageID = s.wageID INNER JOIN EmpHiringInfo ehf ON ehf.EmpHiringInfoID = s....

Update rows in a related table based on condition in parent table.

I have a table TABLE1 (PARENT TABLE) with columns StaffID (PK) Name CategoryID (FK) I also have another related table TABLE2 (RELATED TABLE) with columns LeaveID (PK) StaffId (FK) StartDate What i want to do is write a T-SQL query to update StartDate column of all rows in TABLE2 whose CategoryID in TABLE1 = '3' TABLE2 is rela...