SQL

  The following SQL will drop all SQL Server objects within a database.   /* Drop all non-system stored procs */ DECLARE @name VARCHAR(128) DECLARE @SQL VARCHAR(254) SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name]) WHILE @name is not null BEGIN     SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'     EXEC (@SQL)     PRINT 'Dropped Procedure: ' + @name...

category: SQL Server SQL

In order to concatenate strings (delimited by with a string) from multiple rows in a SQL Table to a single field the Coalesce command is the one to use.  Typically COALESCE is used to return a single field value which represents multiple rows concatenated by a string. DECLARE @EmployeeList varchar(100)   SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') + CAST(Emp_UniqueID AS varchar(5)) FROM SalesCallsEmployees WHERE SalCal_UniqueID = 1 ...

category: SQL

Where the column name matches exactly… SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name = '{text}' ) Where the column name is like… SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name like '%{text}%' ) The following will show all occurrences of the column in any object SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%doctorid%'

category: SQL

About Me

An engineer by training and a software developer at heart. My techniques and approaches meld engineering approaches with software technology.

Core to these principles is a systematic approach to the development of software with a strong lifecycle and process management emphasis through adoption of mature technologies.

Ten years designing heavy structural steel and concrete structures and 12 years in the software development profession have embedded strong project management and business knowledge in my approaches.

Subscribe to Rss Feed


Follow me on twitter @dyardy