I am trying to detect if the server is running Express Edition.
I have the following t sql.
DECLARE @edition varchar(50); set @edition = cast((select SERVERPROPERTY ('edition')) as varchar) print @edition
In my instance, @edition = Express Edition (64-bit)
How can I do the following? (C# inspired).
DECLARE @isExpress bit; set @isExpress = @edition.StartsWith('Express Edition');
CONTAINS is a predicate used in the WHERE clause of a Transact-SQL SELECT statement to perform SQL Server full-text search on full-text indexed columns containing character-based data types. CONTAINS can search for: A word or phrase. The prefix of a word or phrase.
For Microsoft SQL Server, CONTAINS() allows for a full text pattern match SQL search queries on your table. It returns a boolean value that indicates whether the function is truthy or falsy. SELECT <columnName> FROM <yourTable> WHERE CONTAINS (<columnName>, '<yourSubstring>');
ssll If you want to match the start of the string you should use 'ss%' instead. select * from table_name where column_name line 'ss%'; this query will return only ssll.
StartsWith
a) left(@edition, 15) = 'Express Edition' b) charindex('Express Edition', @edition) = 1
Contains
charindex('Express Edition', @edition) >= 1
Examples
left
function
set @isExpress = case when left(@edition, 15) = 'Express Edition' then 1 else 0 end
iif
function (starting with SQL Server 2012)
set @isExpress = iif(left(@edition, 15) = 'Express Edition', 1, 0);
charindex
function
set @isExpress = iif(charindex('Express Edition', @edition) = 1, 1, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With