Luciano Evaristo Guerche

A brazilian geek interested in .NET technologies

About Me

Browse by Tags

All Tags » sql server (RSS)
dbo.PartitionLeft, dbo.PartitionRight and dbo.Partition
IF EXISTS( SELECT * FROM dbo . sysobjects WHERE id = OBJECT_ID ( N'[dbo].[PartitionLeft]' ) AND xtype in ( N'FN' , N'IF' , N'TF' ) ) BEGIN DROP FUNCTION [dbo] . [PartitionLeft] END GO CREATE FUNCTION [dbo] . [PartitionLeft] ( @value bigint , @min bigint...
CREATE FUNCTION dbo.IsValidCPF
IF EXISTS( SELECT * FROM dbo . sysobjects WHERE id = object_id ( N'[dbo].[IsValidCPF]' ) AND xtype in ( N'FN' , N'IF' , N'TF' ) ) BEGIN DROP FUNCTION [dbo] . [IsValidCPF] END GO CREATE FUNCTION dbo . IsValidCPF ( @CPF varchar ( 11 ) ) RETURNS bit AS BEGIN...
How to mimic Microsoft Access's FIRST and LAST clauses on SQL Server 2k, 7.0 and 6.5
Suppose I have the following query run against Pubs database SELECT employee . emp_id , employee . fname , employee . minit , employee . lname , employee . job_id , jobs . job_desc , employee . job_lvl , employee . pub_id , employee . hire_date FROM employee...
ISNULL + NULLIF instead of CASE WHEN
Today I had to write a SQL statement quite similar to the sample below: SELECT ProductID, ProductName, CASE WHEN ProductDescription IS NULL OR ProductDescription = '' THEN '<no description>' ELSE ProductDescription END AS ProductDescription...
Roman's Weekly SQL Server Tip - Case of mistaken @@IDENTITY
Just read Roman's Weekly SQL Server Tip - Case of mistaken @@IDENTITY
Something I learnt about SQL table type this week
Q: When I try to compile the procedure below I get the error Must declare the variable '@TableType'. Can you guess why the following stored procedure does not compile? CREATE PROCEDURE #SystemTablesAndColumns AS DECLARE @TableType TABLE (id int...
Boring SQL server message errors
Last week, I created some scripts to move data from an old database to a new one. Some tables consisted of many fields and the old ones were not typed, that is, all fields where char, varchar, etc. INSERT INTO targetTable ( targetField1, targetField2...
DA, aka Data Administrators + ERWin = MESS
Last week, I found out DA team, using ERWin to synchronize models and databases, had messed up with some foreign keys on a database I architected for an application I am developing and the FKs were missing. Then the question "How to find out which...
How to list nullable bit columns with no default bound with sp_bindefault
I generally create bit columns as NOT NULL DEFAULT dbo.BIT_NO, which in turn is a SQL server default which translates to 0. Today, I found out somebody on my team had created lots of bit fields on several tables as NULL with no default set. So I created...
Problem working with named transactions inside stored procedures
I created the following two stored procedures using named transactions inside them /* ********************************************************** */ CREATE PROCEDURE #WorkingWithNamedTransactionsOne -- This procedure does not raise error AS DECLARE @ERROR...
More Posts Next page »