sql-server-2005

Why am I causing a Clustered Index Update?

I'm executing the following statement: UPDATE TOP(1) dbo.userAccountInfo SET Flags = Flags | @AddValue WHERE ID = @ID; The column 'ID' is an INT PRIMARY KEY with IDENTITY constraints. Flags is a BIGINT NOT NULL. The execution path indicates that a Clustered Index Update is occurring. A very expensive operation. The...

PHP & SQL Server - field names truncated

I have discovered that results coming from my SQL Server are having the field names truncated: $query = "SELECT some_really_really_long_field_name FROM ..." ... print_r($row); array( 'some_really_really_long_field_n' => 'value' ) Does anyone know how to avoid this behaviour? I think the database driver is ADODB. So you don't ha...

SQL Server 2005 - Table Functions in a Select statement

I have a table called PurchaseOrderDetail. TABLE PurchaseOrderDetail PurchaseOrderDetail int, Comments nvarchar(500) In the Comments field of each item I have a ‘;’ separated list that stores A Contract Name, Contract No, License Name, License Version. i.e. PurchaseOrderDetail Comments 1 'Microsoft Offic...

How to show the execution time before query result will display

How to show the execution time before query result will display ...

SignByCert and the maximum size of sign

I have following table CREATE TABLE User ( email sysname NOT NULL, sign varbinary(256) NULL ); sysname in SQL Server 2005/2008 has the same size as nvarchar(128) - which I'm assuming is 256 bytes. I'm using SignByCert(..., email, ...) function to produce a signature of 'email' column. Can I make any assumptions about the max...

Connect to SQL Server 2005 from Perl and do a SELECT

How do I do a SELECT on a SQL Server 2005 from a Perl script? ...

How to source control stored procedures with SQL Server 2005 and Visual Source Safe 2005?

I am trying to follow the steps on the following site http://msdn.microsoft.com/en-us/library/ms181089(VS.80).aspx But I couldn't find the "Data View window and an Add to Source Control command" in the SQL Managment Studio. Then I tried to Modify a stored procedure and then I clicked on the "Change Source Control" button at the "Source...

How did my database security fail?

In a couple of my tables in my SQL Server 2005 database all of my data has been erased. Is there anyway to get a log in SQL Server of all the statements that have ran in the past day? I am trying to find out if someone did this on accident, there is a vulnerability in my web app, or the actual DB has been compromised. ...

How to Display data in a linear fashion

Using this example found here I have a report i want to create which will show me infomation like the following: Account ID , DateEntered, DateFirst contact was made, Dealt by, Date 2nd contact was made, Dealt by.... However all this information is heald in one table but the info comes like this (See example i...

Log changes to database table with trigger

I am looking for a good way to log changes that occur on a particular set of tables in my SQL Server 2005 database. I believe the best way to do this is through a trigger that get's executed on updates and deletes. Is there anyway to grab the actual statement that is being ran? Once I have the statement I can easily log it someplace else...

SSIS: Is there a way to deploy packages to multiple SQL Server 2005 instances

Does anyone have any advice or techniques for deploying SSIS packages to the Integration services database. Basically I maintain a number of SSIS packages that need to get deployed to several environments (dev, test and production), there is a need to change the individual database connections as well. I would like to automate the proc...

SQL Server 2005 and Full Text Search Performance problem

Dear All, I have a heavy table on sql server 2005 with enable full text search on it, I want to get top N newest data by id or insert date with specific full text. some query result with "Containstable" return over 500,000 record and take over 1 min, that is very bad, also top n by rank not good for me because maybe return old data ...

What caused a Private Bytes on SQL Server 2005?

My Server is Windows 2003 and SQL Server 2005 Standard. 3 GB of RAM. After run my client program for a while a Private Bytes up to 1.7 GB and never come down. only process 51 with status "runnable". Click details. create table #tmpDBCCinputbuffer ( [Event Type] nvarchar(512), [Parameters] int, [EventInfo] nvarchar(512)) insert into #...

SQL Server query grouped by max value in column

**Update: using the Rank() over partition syntax available in MS SQL Server 2005 does indeed point me in the right direction, it (or maybe I should write "I") is unable to give me the results I need without resorting to enumerating rows in code. For example, if we select TOP (1) of rank, I get only one value, ie., slot 1. If I use MA...

In Memory OleDbConnection to Excel File

I would like to open an OleDbConnection to an Excel file that's in memory as a FileStream. Does anyone know if this is possible and how to accomplish it? Big picture I would like to pass the file bytes into a .NET CLR Stored Procedure and extract the data. Perhaps there's a better way to do this that I've not considered. Thanks in ad...

When is IS_MEMBER set in Sql Server?

I am trying to get IS_MEMBER working in a UDF in Sql Server 2005. I have a windows group "Domain\TestGroup". I allocate my Login "Domain\Kieran" to it. select SUSER_NAME(); gives "Domain\Kieran" but select IS_MEMBER('Domain\TestGroup'); returns NULL. ...

T-SQL: How to log erroneous entries during import

Hi, I do an import and convert columns to other datatypes. During the import I check, if I can convert the values stored in the columns into the target datatypes. If not I put a default value, e.g. I convert a string to int and when I cannot convert the string I insert -1. At this moment it would be great if I could log the erroneous e...

Java/MSSQL: java.sql.SQLException Invalid object name 'TableName'.

I'm trying to move a java application from an old server to a new server. The application runs on Tomcat, uses Microsoft SQL Server as the backend DB, and used a system DSN defined in Data Sources (ODBC) to decide where to connect to. The old server used Windows 2000/SQL server 2000, the new server uses Windows 2003/SQL Server 2005. T...

How can I page through data using nHibernate using a CTE?

Is there any example code someone can show me that will page through data in a given table, and use CTE's under the hood? Is nhibernate suppose to work across various databases out of the box? I am using MS SQL Server 2008 now, but what if the client wants to use Oracle someday? ...

Slow inital query when using FreeTextTable in SQL Server 2005

The following FreeTextTable query takes > 10 seconds on the first request, but about a second for subsequent requests: SELECT [Key], [Rank] INTO #matches FROM FREETEXTTABLE(Book, [Description], @searchWord) After approx. 10 minutes of inactivity the next request will once again take > 10 seconds. This seems like the freetext cache is ...