SQL Server 2000: How to exit a stored procedure?

You can use RETURN to stop execution of a stored procedure immediately. Quote taken from Books Online: Exits unconditionally from a query or procedure. RETURN is immediate and complete and can be used at any point to exit from a procedure, batch, or statement block. Statements that follow RETURN are not executed. Out of paranoia, … Read more

Is SQL IN bad for performance?

There are several considerations when writing a query using the IN operator that can have an effect on performance. First, IN clauses are generally internally rewritten by most databases to use the OR logical connective. So col IN (‘a’,’b’,’c’) is rewritten to: (COL = ‘a’) OR (COL = ‘b’) or (COL = ‘c’). The execution … Read more

How do I drop a function if it already exists?

IF EXISTS ( SELECT * FROM sysobjects WHERE id = object_id(N’function_name’) AND xtype IN (N’FN’, N’IF’, N’TF’) ) DROP FUNCTION function_name GO If you want to avoid the sys* tables, you could instead do (from here in example A): IF object_id(N’function_name’, N’FN’) IS NOT NULL DROP FUNCTION function_name GO The main thing to catch is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)