SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. USE [master]
  2. GO
  3. CREATE DATABASE [MyDatabase]
  4.  CONTAINMENT = NONE
  5.  ON  PRIMARY
  6. ( NAME = N'MyDatabase', FILENAME = N'C:DatabasesDataMyDatabase.mdf' , SIZE = 100KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
  7.  LOG ON
  8. ( NAME = N'MyDatabase_log', FILENAME = N'C:DatabasesDataMyDatabase_log.ldf' , SIZE = 100KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
  9. GO
  10. ALTER DATABASE [MyDatabase] SET COMPATIBILITY_LEVEL = 100
  11. GO
  12. IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
  13. begin
  14. EXEC [MyDatabase].[dbo].[sp_fulltext_database] @action = 'enable'
  15. end
  16. GO
  17. ALTER DATABASE [MyDatabase] SET ANSI_NULL_DEFAULT OFF
  18. ...
  19. GO
  20. /****** Object:  DatabaseRole [StoreRW]    Script Date: 22.02.2019 10:14:14 ******/
  21. CREATE ROLE [StoreRW]
  22. GO
  23. ...
  24. GO
  25. CREATE TABLE [dbo].[MyTabale1](
  26. ...
  27.      
  28. $My="$ms.Management.Smo" #
  29. $s = new-object ("$My.Server") $DataSource
  30. if ($s.Version -eq  $null ){Throw "Can't find the instance $Datasource"}
  31. $ver = $s.Version
  32. echo " SQL Server version is $ver"
  33. $db= $s.Databases[$Database]
  34. if ($db.name -ne $Database){Throw "Can't find the database '$Database' in $Datasource"};
  35. $transfer = new-object ("$My.Transfer") $db
  36. if ($transfer -eq  $null ){Throw "Can't create transfer object"}
  37. $transfer.Options.Default = $true;
  38. $transfer.Options.ScriptBatchTerminator = $true # this only goes to the file
  39. $transfer.Options.ToFileOnly = $true # this only goes to the file
  40.  
  41. $transfer.Options.ExtendedProperties = $true;
  42. $transfer.Options.IncludeDatabaseContext = $true;
  43. $transfer.Options.WithDependencies = $true;
  44. $transfer.Options.IncludeHeaders = $true;
  45. $transfer.Options.SchemaQualify = $true;
  46. $transfer.Options.DriAll = $true;
  47.  
  48. $transfer.Options.ScriptData = $true;
  49. $transfer.Options.ScriptSchema = $true;
  50. $transfer.Options.FileName = $BackupFile;
  51. $tmp = $transfer.Options;
  52. echo " Transfer options are: $tmp";
  53. $transfer.EnumScriptTransfer();
  54. echo "Scripting database '$dbName' to '$BackupFile' done"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top