Query for searching the entire database for a string value To run this query in your own senerio, just change the ‘Cal’ to any string you desire DECLARE @Database Varchar(255) DECLARE @Schema Varchar(255) DECLARE @TableName Varchar(255) DECLARE @ColumnName Varchar(255) DECLARE @SqlCmd Varchar(255) DECLARE @Search Varchar(1000) SET @Search = 'Gary' SET @Search = '''%'+@Search+'%''' –PRINT @Search [...]
Category Archives: SQL
Kill Active Processes for a particular SQL Database
Below is a SQL script that I use all the time when it comes down to hung procedures and any unwanted processes that are left open. This below T-SQL could also be turned into a procedure quite easily and used as a cleanup job before running any backups. DECLARE @p_SPID int, @p_SQL nvarchar(2000), @dbName nvarchar(100) [...]
Sql Object Schema
So inorder to Find a table schema in sql you have two options — this will show all tables within this database SP_TABLES — this is a more selective search select * from INFORMATION_SCHEMA.tables WHERE TABLE_NAME = this can also be done with columns — this will show all column definations within the table specfied [...]
using OPENROWSET to import excel files into Sql tables
As I am currently looking into ways in which I could automate dataloading from multiple file formats using stored procedures. I stumbled accross OPENROWSET, which proves to have more than what i bargined for with being able to support multple file types which include (access, Excel, csv, text) So for this post I am looking [...]