sql-server-2005

Index varchar on MS SQL Server 2005

I need to index a varchar field on my table in MS SQL Server 2005, but it's not clear to me how to do so. If I try to add a non-clustered index on the field, it says "Column 'xxxx' in table 'mytable' is of a type that is invalid for use as a key column in an index" My table has an auto-increment int ID that is set as the primary key on...

Sql Server string to date conversion

I want to convert a string like this: '10/15/2008 10:06:32 PM' into the equivalent DATETIME value in Sql Server. In Oracle, I would say this: TO_DATE('10/15/2008 10:06:32 PM','MM/DD/YYYY HH:MI:SS AM') This question implies that I must parse the string into one of the standard formats, and then convert using one of those codes. Th...

SQL Query for Parent Child Relationship

I have db table with parent child relationship as: NodeId NodeName ParentId ------------------------------ 1 Node1 0 2 Node2 0 3 Node3 1 4 Node4 1 5 Node5 3 6 Node6 5 7 Node7 2 Here parentId = 0 means that it is a root level node. N...

Best Practice for Database Encryption in SQL Server 2005

I need to develop an application which stores data in a SQL Server 2005 database (the app itself will be either a WCF Service or an Asp.Net Web Service). Now, this data is supremely confidential, and I need to have it stored in an encrypted form in the database. So, I am wondering what the best practices are around this. I know that th...

distributed transaction between two MS SQL Server 2005

I need to make DISTRIBUTED TRANSACTION between two MS SQL Server 2005, it drops an error that NO ACTIVE TRANSACTION IS PRESENT or smth like this. DTCTESTER programs drops an error that transaction could not be done. btw 135 port is open on the firewall. Maybe anyone knows what a problem, or have a suggestion? ...

How can I use RLIKE MySQL function inside of SQL Server 2005?

I need to run a RLIKE query on a database mmoved from MySQL to SQL Server 2005 however having problems replicating the "RLIKE" functionality that MySQL provides. Does anyone have any ideas? Cheers, Chris ...

SQL Server 2005 - Restoring an encrypted DB on a different server

I have backed up an encrypted DB (symmetric key/certificate) and restored it on a different server. Unfortuantely we're having problems with the decryption... hoping someone can help. In the restored db, I can see the Symmetric Key and the Certificate in SSMS, but when I try to Open the key using the cert ( open symmetric key Key...

Why or How does FREETEXTTABLE give a rank value higher then others.

There is a store procedure that uses FREETEXTTABLE twice on two tables and then merges the results and returns the top 50. The problem is if I do a search on "Women of Brewster", the results returns "Confession of an ex doofus motha" with a rank of 143 from table A and second "Women of Brewster Place" with a rank of 102 from table B. ...

SQL Server 2005 - best way to move data between two databases when primary keys have changed

Hi, i know this should be db 101, but its just not as clear as it can be for me. I am using SQL2005 express and i want to copy data from databaseA to databaseB. DatabaseB already contains existing data - it may even contain data with pk's that have changed or dont exist - for example: DataBase A pk1 = peaches pk2 = apples DataBase B ...

Installing SqlServer 2005 Express using InstallShield and creating a unique named instance

I'm using Installshield 2008 express to create an installation package. My application relies on Sql Server 2005 express edition. I know I am able to check the "microsoft sql server 2005 express" prerequisite under the redistributables tab. However, this leaves the installation entirely in the hands of the end user, and if he/she chooses...

How do I start extending MS SQL Reporting Services?

The reports I can churn out in SQL Server 2005 Reporting Services using the MS Business Intelligence Development Studio is rather limited for what I want to do. I have had a look at a similiar stackoverflow question and have had a browse through the MSDN website. I have managed to add some additional functionality from examples I've foun...

How to get the statistics existing on a column, if any?

I want to check in Transact SQL if a specific column in a table has statistics and if so to get them all. ...

access to SQL copy

Hi Guys We have an Access DB which has a set of local tables and input forms etc. in which a user maintains their data. We also have a SQL DB with the same tables which is used to displays the data in a web search form. What is the best way to allow the user to udate his changes to the SQL db while keeping the working copy local so he...

Query for the average call length for all users for a day

(sql server 2005) A person uses their cell phone multiple times per day, and the length of their calls vary. I am tracking the length of the calls in a table: Table: Calls [callID, memberID, startTime, duration] I need to a query to return the average call length for users PER DAY. Per day means, if a user used the phone 3 times, fi...

Using XQuery in Linq To SQL?

Let's say I have a table that has a column of XML type data. Within SQL, I can execute the following statement: select top 10 *, Content.value('(/root/item/value)[1]', 'float') as Value from xmltabletest where Content.value('(/root/item/MessageType)[1]', 'int') = 1 The result set contains only the records matching ...

How to determine total number of open/active connections in ms sql server 2005

My PHP/MS Sql Server 2005/win 2003 Application occasionally becomes very unresponsive, the memory/cpu usage does not spike. If i try to open any new connection from sql management studio, then the it just hangs at the open connection dialog box. how to deterime the total number of active connections ms sql server 2005 ...

SQL Server application role, performance hit

I plan to use MS SQL Server 2005 application roles in my application. I will start the role by executing the *sp_setapprole* and finish by executing the *sp_unsetapprole* SPs. The application is implemented in ASP.NET. I've read that connection pooling doesn't work with application pooling and there is no way to react on connection disc...

Can SSMA for migrating Access databases to SQL Server 2005 be automated?

I need to migrate Access databases to SQL Server 2005. Since this needs to be done from within a setup so that a customers' installation is transparently migrated to SQL Server 2005, I wonder if it is possible to automate the SSMA toolkit from Microsoft. ...

SQL Server 2000/2005 identity column + replication

I have looked at some resources already and just want to clarify and get an opinion. First of all to totally avoid any problems we could just not bother using identity columns as primary keys instead have them generated ourselves and just have those values replicated both ways presuming they are always unique at any time of creation. F...

Best Approach to Brownfield Database Development in SQL Server 2000/2005

I've recently taken over development on a SQL Server 2000 database that needs some help. We're planning on upgrading it to SQL Server 2005 soon. This database has no audit fields on the tables (CreatedBy, CreatedDate, etc.), no foreign keys, and terrible overall design. There are half a dozen programs that directly access the database...