sql-server

COALESCE... Can anybody help me to optimize this code?

Can anybody help me to optimize this code? At present it takes 17 seconds. set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO --SpResumeSearch NULL,null,null,null,null,null,null,null,null,null,null,NULL,null,null,null,null,null,null,null,0,10,NULL ALTER PROCEDURE [dbo].[SpResumeSearch] @Keyword varchar(50) = NULL, @JobCategoryId in...

Is SQL Server Express good enough for a developer, or should they get Developer edition?

Just wondering if it's worth it for a developer to use SQL Server 2005/2008 Developer Edition instead of the bundled SQL Server Express edition that comes with Visual Studio. I'm talking about for initial development of a website, where you need to create SQL scripts to generate the tables and things like that. I know with Express it's...

How to handle db constraint violations in the user interface?

We implement the majority of our business rules in the database, using stored procs. I can never decide how best to pass data constraint violation errors from the database back to the user interface. The constraints I'm talking about are tied more to business rules than data integrity. For example, a db error such as "Cannot insert dup...

connecting to a sql server using sqlconnection class

Hi Guys.I am trying to connect to a Sql Server in my apllication using the following code : SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = "Data Source = (local);Initial Catalag = Inventory; Persist Security Info = false; Integrated Secu...

Efficient transaction, record locking

I've got a stored procedure, which selects 1 record back. the stored procedure could be called from several different applications on different PCs. The idea is that the stored procedure brings back the next record that needs to be processed, and if two applications call the stored proc at the same time, the same record should not be b...

SQLServer try catch performance

Has anyone found any performance boost/tradoff of using BEGIN TRY..END TRY in sql server 2008, vs the old IF @@ERROR <> 0? Just curious to know if there are performance penalties or not. ...

Huge table

I read your article(SQL Server partitioning: not the answer to everything) and being amazing of use partitioning for my case or not I must to store about 1000 record per a second this data is about location of mobile nodes, these data make my database too huge do you think i must partitioning my database or not(I have so much reporting ...

How to escape strings in MSSQL using PHP?

I'm looking for the alternative of mysql_real_escape_string() for MSSQL. Is addslashes() my best option or there is another alternative function that can be used? Edit: Alternative for mysql_error() would also be useful. ...

How to get Insert id in MSSQL in PHP?

What the question title says. With a query such as SELECT @@IDENTITY AS ins_id, do I need to supply the table name or any other info to specify which table/database i'm talking about? ...

First Name Variations in a Database

I am trying to determine what the best way is to find variations of a first name in a database. For example, I search for Bill Smith. I would like it return "Bill Smith", obviously, but I would also like it to return "William Smith", or "Billy Smith", or even "Willy Smith". My initial thought was to build a first name hierarchy, but I...

Implementing a custom TraceListener in .NET

I am looking for best practices to implement a TraceListener that will write logs inside SQL server from an ASP.NET application. What are the things that should be taken into account when implementing such a class in order to avoid performance reduction? Will stored procedures be faster than plain ADO.NET INSERT statements? I reall...

How can I retrieve the identities of rows that were inserted through insert...select?

I am inserting records through a query similar to this one: insert into tbl_xyz select field1 from tbl_abc Now I would like to retreive the newly generated IDENTITY Values of the inserted records. How do I do this with minimum amount of locking and maximum reliability? ...

SQL Server file and filegroup

Hello everyone, I can not think of any reasons why we need to have multiple files inside a file group. The reason why I think of this way is we can control from T-SQL (end user) level about file group, but can not control from T-SQL (end user) level about individual files of a file group. Any comments or ideas why files are still needed...

What's the best way to diff two database backup files with MS Sql Server 2005?

I have two database backup files. I would like to know if there is any difference between the two. I could go row by row, field by field and do a diff (I'm not looking for differences in schema but rather data, although I expect the schema to remain the same). Can I run some sort of checksum on the files, or do I have to go through the ...

Insert all values of a table into another table in SQL

I am trying to insert all values of one table into another. But the insert statement accepts values, but i would like it to accept a select * from the initial_Table. Is this possible? ...

SQL Alert when stored procedure executes for too long

I would like to set up a SQL Server 2008 Alert to notify me when any procedure executes for 1 second or longer (just an example). Any ideas? EDIT: Okay, it seems this is not possible. But, just to nudge you in another direction, I know that there are statistics tables in the master database which hold compilation counts, number of cal...

Can SQL Server 2000 be made to populate a fulltext catalogue without blocking the tables it is reading?

I have a database server on SQL Server 2000 (yes I know...) with fulltext catalogues on some of its tables. I'm currently doing a full population overnight in quiet time, and I'd like to be able to update the catalogues during the day so that new data can be considered in searches. The problem I've noticed is that when an incremental po...

Sql Server Backup Sizes

Does anyone have real world experience of backup compression in Sql 2008, I'd like to know how it performs compared to Sql 2005 + winrar. Currently when I back up a I get a 14G file. Using rar shrinks it to <400M, a massive saving. Most of the data is similar, being figures from the stock market so I guess that makes it easy to compress....

Change type of a column with numbers from varchar to int

We have two columns in a database which is currently of type varchar(16). Thing is, it contains numbers and always will contain numbers. We therefore want to change its type to integer. But the problem is that it of course already contains data. Is there any way we can change the type of that column from varchar to int, and not lose al...

Why is query slow but procedure fast on SQL Server?

Why is it that if I run my query as a parameterized procedure it runs 10 times faster then if I run it directly as a parameterized query? I'm using the exact same query in both cases, and it doesn't matter if I'm calling from Management Studio or an SqlCommand from code. EDIT: The execution plan looks different. So, why? I'm calling ...