You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
SELECT field_to_compare FROM Destination_Table
EXCEPT
SELECT field_to_compare FROM Source_Table
139
T-SQL
Datenbank-Administration
Alle Transaktion/Jounal-Log Files verkleinern
-- The script is designed to work on a sql server -- 2008R2. However it works on 2005 and sql server
-- 2012 instances.
-- It shrinks all log files for the databases
-- created by users
-- Written by Igor Micev, 2012
-- from SQLServerCentral.com
declare @logname nvarchar(128)
declare @dbname nvarchar(128)
declare @dynamic_command nvarchar(1024)
set @dynamic_command = null
declare log_cursor cursor for
select db_name(mf.database_id),name
from sys.master_files mf
where mf.database_id not in (1,2,3,4) --avoid system databases
and mf.name not like 'ReportServer$%'
and right(mf.physical_name,4) = '.ldf' and mf.state_desc='online'
open log_cursor
fetch next from log_cursor into @dbname,@logname
while @@fetch_status = 0
begin
set @dynamic_command = 'USE '+@dbname+' DBCC SHRINKFILE(N'''+@logname+''',0,TRUNCATEONLY)'
exec sp_executesql @dynamic_command
fetch next from log_cursor into @dbname,@logname
set @dynamic_command = null
end
close log_cursor
deallocate log_cursor
140
T-SQL
Datenbank
Aktuellen Datenbanknamen ausgeben
SELECT DB_NAME() AS DB_Name
235
MySQL
Datenbank
Aktuellen Datenbanknamen ausgeben
SELECT DATABASE() AS DB_Name;
141
SQLite
Datenbank
Fremdschlüsselprüfung aktivieren
-- http://www.sqlite.org/foreignkeys.html
PRAGMA foreign_keys = ON;
-- !! this is only valid for the current session.
-- If you want to use this permanent, you have to use this statement every time you start a new session
-- Gets only result with 4 "/" in the the field relativePath
SELECT
id
,albumRoot
,relativePath
,date
,caption
,collection
,icon
,LENGTH(relativePath) - LENGTH(REPLACE(relativePath,'/','')) AS `occurrences`
FROM Albums
WHERE LENGTH(relativePath) - LENGTH(REPLACE(relativePath,'/',''))=4
;
145
JavaScript
Strings
Anzahl an Zeichen in einem String ermitteln
myString = "This is a string, containing some words. Try it, if you don't believe ;-)";
// Get the count of commas in the string:
cntCommas = myString.split(",").length-1;
// => 2