sql-server

SQL Server full text query across multiple tables - why so slow?

Hi. I'm trying to understand the performance of an SQL Server 2008 full-text query I am constructing. The following query, using a full-text index, returns the correct results immediately: SELECT O.ID, O.Name FROM dbo.EventOccurrence O WHERE FREETEXT(O.Name, 'query') ie, all EventOccurrences with the word 'query' in thei...

In a SQL XDL File, how do I read the waitresource attribute on process nodes which are deadlocking?

On SQL Server 2005, I'm getting a deadlock when updating two different keys in the same table. note from below that these two waitresources have the same beginning part, but different ending parts. waitresource="KEY: 6:72057594090487808 (d900ed5a6cc6)" and waitresource="KEY: 6:72057594090487808 (d900fb5261bb)" These two keys ar...

Maintainging default values when importing a sql database into a vb.net application

Hello, I am trying to copy a sql database into a vb.net application however it is not maintaining the default values when I do this. Is it possible to import the default values and have them automatically assigned when creating a new row or do I have to manually assign the default values again in my code? ...

Why sometimes I get "Cursor not returned from Query" from a valid select statement

I have some valid select statements that when I send to MSSQL2005 sometimes return the error "Cursor not returned from Query". It happens with different queries that work fine 99% of the time, and the only thing they all have in common is the use of several joins and some group by. Pretty standard queries. How can I trace this and find...

Integration transport choice (Oracle + SQL Server)

We have several systems with Oracle (A) and SQL Server (B) databases on backend. I have to consolidate data from those systems into the new SQL Server database. Something like that: (A) =>|---------------| | some software | => SQL Server (B) =>|---------------| where some software is: transport (A and B systems located in th...

Select dynamic string has a different value when referenced in Where clause

I dynamically select a string built using another string. So, if string1='David Banner', then MyDynamicString should be 'DBanne' Select ... , Left( left((select top 1 strval from dbo.SPLIT(string1,' ')) //first word ,1) //first character + (select top 1 strval from dbo.SPLIT(string1,' ') //second word wher...

Is it possible to set a primary key to a view?

Is it possible to set a primary key to a view in SQLServer 2008? ...

.net Encrypting Database Tables

I am delivering a module for a website that will collect information from a user and make appropriate calculations. The client wants any data collected from the user to be encrypted. We are using SQL express 2005 as the database. Thanks in advance. ...

SQL Server CLR to embed business logic and schedule execution with SQL Server Agent

Hi, I have the business logic of an workflow-like application in a C# class library, but at end of each month certain process in the library needs to be invoked, i thought that the ideal mechanism to invoke this scheduled execution is using the Sql server agent (sql job preferably, althought i'm open to even go into SSIS hell if its abs...

Getting SqlServer2005 error: backup set holds a backup of a database other than the existing 'DbName' database

I am trying to upgrade from a server running SqlServer2005 (no service packs) to a server running SqlServer2005 service pack 3. I am trying to copy the databases from one to another by doing a backup on one, then a restore on the other. I am using ssms. When I try to restore a backup of, call it DbName, created on the first server,...

Does Access have any issues with unicode capable data types like nvarchar in SQL Server?

I am using Access 2003 as a front end UI for a SQL Server 2008 database. In looking at my SQL Server database design I am wondering if nvarchar was the right choice to use over varchar. I chose nvarchar because I thought it would be useful in case any characters represented by unicode needed to be entered. However, I didn't think about a...

Does the order of columns matter in a group by clause?

If I have two columns, one with very high cardinality and one with very low cardinality (unique # of values), does it matter in which order I group by? Here's an example: select dimensionName, dimensionCategory, sum(someFact) from SomeFact f join SomeDim d on f.dimensionKey = d.dimensionKey group by d.dimensionNa...

How Can I Generate Random Unqiue Numbers in C#

public int GenPurchaseOrderNum() { Random random = new Random(); _uniqueNum = random.Next(13287, 21439); return UniqueNum; } I removed unique constraint from the PONumber column in the db because an employee should only generate P.O. # when the deal is set. Otherwise, P.O. # would have 0. P.O. Number used to have unique co...

Use SmallDateType in Model-First Entity Framework

I can't help but feel I am missing something but to this day I cannot find the answer. I am doing a model-first entity framework and have a few properties set as DateTime. These translate to DateTime in the database - but I would like to use SmallDateTime. In my case, getting down to seconds and milliseconds just isn't worth the doub...

Fulltext Search in SQL Server 2008 Step by step

I am new to FullText Search. Can anyone explains me Fulltext Search in SQL Server 2008 Step by step Thanks ...

Alternatives to Red Gate SQL Comparison SDK?

I've been using the Red Gate SQL Comparison API in a project that's getting long in the tooth. We use a fraction of its abilities and I am evaluating other options. Our scenario is basically this: We have two SQL Server 2008 databases that can be assumed to have identical schemas. The databases are tiny. Most tables have less than 1...

Enumerate available SQL Servers from .Net

Anyone know if there is a more "up to date" way of enumerating all available SQL Server instances via .Net, i.e. without using System.Data - DataTable/DataRow bits. SqlDataSourceEnumerator sqlEnumerator = SqlDataSourceEnumerator.Instance; DataTable dt = sqlEnumerator.GetDataSources(); foreach(DataRow row in dt.Rows) { Console.WriteL...

customer.pk_name joining transactions.fk_name vs. customer.pk_id [serial] joining transactions.fk_id [integer]

Pawnshop Application (any RDBMS): one-to-many relationship where each customer (master) can have many transactions (detail). customer( id serial, pk_name char(30), {PATERNAL-NAME MATERNAL-NAME, FIRST-NAME MIDDLE-NAME-INITIAL} [...] ); unique index on id; unique cluster index on pk_name; transaction( fk_name char(30), tran_type char(1...

How to build where clause in SQL Server??

I would like to build the where clase of a sql statement dynamically from hashtable in C#. The key of the hash_table will be the column's name to be inserted and the value of hash_table will be value. string sql_1="SELECT COL_1,COL_2 FROM MY_TABLE"; string sql_2="SELECT * FROM MY_TABLE WHERE COL_3='ABC'"; //note: some statment have wh...

I get an error when implementing tde in SQL Server 2008

USE MyDatabase GO CREATE DATABASE ENCRYPTION KEY WITH ENCRYPTION ALGORITHM = AES_256 BY SERVER CERTIFICATE TDECert GO when i execute this statement in SQL Server 2008 I get the error: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'KEY'. Msg 319, Level 15, State 1, Line 2 Incorrect syntax near the key...