Showing posts with label sql server - print(). Show all posts
Showing posts with label sql server - print(). Show all posts

Tuesday, April 3, 2018

SQL SERVER - How get database instance version

print @@version
Output:
Microsoft SQL Server 2014 (SP2-GDR) (KB4019093) - 12.0.5207.0 (X64) 
 Jul  3 2017 02:25:44 
 Copyright (c) Microsoft Corporation
 Express Edition (64-bit) on Windows NT 6.3  (Build 9600: ) (Hypervisor)

Monday, December 11, 2017

SQL SERVER - How check if database exists

Use this script code:
use master;

/* -- define DB name */

declare @database_name nvarchar( max );  
set @database_name = 'framework'; 

/* -- check if DB exists yet */

if db_id( @database_name ) is not null
begin
  print 'DB exists.';
  /* db exists -> end */
  return;
end;
...