If you’ve been developing in SQL Server for any length of time, you’ve no doubt hit this scenario: You have an existing, working query that produces results your customers or business owners say are correct. Now, you’re asked to change something, or perhaps you find out your existing ...
This method functions well, but it uses the OBJECT_ID() function. OBJECT_ID() will take out ashared schema lock (SCH_S)on the table we pass into it. Shared schema locks are very lightweight, but it is kind of a bummer to have to lock the table itself if we’re just querying met...
IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'Employee' AND column_name = 'LastName' ) PRINT 'Column- LastName Exists' ELSE PRINT 'Column- LastName doesn''t Exists' SQL Copy For more information on INFORMATION_SCHEMA.COLUMNS , please refer to Microsoft documentati...
SQL 2005+ EXECUTE master.sys.sp_MSforeachdb 'USE [?]; if exists(select * from INFORMATION_SCHEMA.tables where TABLE_TYPE=''BASE TABLE'' and TABLE_NAME=''DB_BACKUP_LOG_T'') begin print ''exist in '' + db_name() end' SQL 2000 ...
Recently I was working with a customer wherein our focus was to carry out a performance audit of their multiple MySQL database nodes. We started looking into the stats of the performance schema. While working, the customer raised two interesting questions: how can he make complete use of the...
-- Default to the v11.0 targets path if the targets file for the current VS version is not found --> <SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExi...
SQL Server INFORMATION_SCHEMA Views | See if a Table Exists What is the Problem? When writing queries for a database you might be new to, or one that changes often, you might want to run a quick check to find all the tables in a specific database, or the columns in thedatabase, ...
It does a check-read of every key for each row to verify that they indeed point to the correct row. This may take a long time for a large table that has many indexes. Normally, myisamchk stops after the first error it finds. If you want to obtain more information, you can add ...
Table Partitioning in SQL Server – Step by Step Partitioning in SQL Server task is divided into four steps: Create a File Group Add Files to File Group Create a Partition Function with Ranges Create a Partition Schema with File Groups
-- USAGE: exec sp_GetDDL YourTableName -- or exec sp_GetDDL 'bob.example' -- or exec sp_GetDDL '[schemaname].[tablename]' so if you create a table like this: create table dbo.tallycalendar ( thedate datetime not null primary key, dayofweek varchar(50) null, isholiday bit null ...