Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. use master
  2. go
  3.  
  4. IF DB_ID (N'lab12Grom') IS NOT NULL
  5. DROP DATABASE lab12Grom
  6. GO
  7.  
  8. CREATE DATABASE lab12Grom
  9. GO
  10. USE master;
  11. GO
  12.  
  13. --удаление соединений
  14. DECLARE @kill varchar(8000) = '';
  15.  
  16. SELECT @kill = @kill + 'KILL ' + CONVERT(varchar(5), c.session_id) + ';'
  17. FROM sys.dm_exec_connections AS c
  18. JOIN sys.dm_exec_sessions AS s
  19. ON c.session_id = s.session_id
  20. WHERE c.session_id <> @@SPID
  21. ORDER BY c.connect_time ASC
  22.  
  23. EXEC(@kill)
  24. GO
  25.  
  26. USE lab12Grom
  27. GO
  28.  
  29. IF OBJECT_ID(N'BookAuthors') IS NOT NULL
  30. DROP TABLE BookAuthors
  31. GO
  32.  
  33. CREATE TABLE BookAuthors(
  34. AuthorID INTEGER not null PRIMARY KEY,
  35. FirstName varchar(30) not null,
  36. LastName varchar(30) not null,
  37. );
  38.  
  39. GO
  40.  
  41. INSERT BookAuthors
  42. VALUES (1, 'Alexander', 'Pushkin'),
  43. (2, 'Taras', 'Shevchenko')
  44. go
  45.  
  46. SELECT * FROM BookAuthors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement