{"id":346943,"date":"2023-03-18T15:01:01","date_gmt":"2023-03-18T15:01:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=346943"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2023-03-18T15:01:01","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=346943","title":{"rendered":"<span>\u041d\u0435 \u0443\u0434\u0430\u043b\u044f\u0439\u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0443\u043c\u043e\u043b\u044f\u044e<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041c\u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0438\u0434\u0435\u0442\u044c \u0447\u0443\u0436\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430 T-SQL. \u042f \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u044b\u043a \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0435<\/p>\n<pre><code class=\"sql\">drop table #a drop table #b<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u0430\u043c\u0430 \u0441\u0435\u0431\u044f \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u0442, \u0432\u0438\u0434\u0438\u043c\u043e \u0434\u0443\u043c\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u0440. \u041d\u0443 \u0438\u043b\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 &#171;\u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439&#187;. \u0412\u0434\u0440\u0443\u0433 SQL server \u0437\u0430\u0431\u0443\u0434\u0435\u0442 \u0435\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c? \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u044d\u0442\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0441\u0442\u0440\u0430\u0448\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a SQL server \u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 (\u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043e \u0447\u0435\u043c \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0434\u0430\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0442\u0440\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0446\u0435). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u0442\u0435\u043b\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c, \u0442\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b, \u0438 \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u0442\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p>\u041d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u0430\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0436\u0443\u0442\u043a\u0438\u0439 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d. \u041d\u0435 \u0437\u043d\u0430\u044e, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u043b\u0441\u044f. <\/p>\n<p>\u0412\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435:<\/p>\n<pre><code class=\"sql\">  if object_id('tempdb..#mytemp') is not null     DROP TABLE #mytemp   create table #mytemp (...)<\/code><\/pre>\n<p>\u041c\u043d\u0435 \u043e\u0431\u0438\u0434\u043d\u043e, \u0447\u0442\u043e SQL server \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u0438\u0434\u0438\u043e\u0442\u043e\u043c <em>\u0441\u043e \u0441\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0442 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u044e\u043d\u044f\u043c\u0438<\/em>, \u0438\u0434\u0438\u043e\u0442\u043e\u043c, \u043d\u0435\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u043c \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u043e \u0432\u0430\u0436\u043d\u0435\u0435 \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u043e\u0434 &#8212; \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0431\u043e\u043c\u0431\u0430 \u0441 \u0447\u0430\u0441\u043e\u0432\u044b\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c.<\/p>\n<p>\u041f\u043e\u043a\u0430\u0436\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443:<\/p>\n<pre><code class=\"sql\">create procedure ALPHA as   create table #mytemp (n int, ALPHA varchar(128))   insert into #mytemp select 1, 'ALPHA'   select 1 as point, * from #mytemp   exec BETA   select 2 as point, * from #mytemp GO<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 BETA:<\/p>\n<pre><code class=\"sql\">create procedure BETA as   create table #mytemp (n int, BETA varchar(128))   insert into #mytemp select 1, 'BETA'   select 3 as point, * from #mytemp GO <\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 ALPHA \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u0438\u0434\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u0432\u043e\u0435\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9f8\/15f\/d34\/9f815fd345db54d067c7ea447c7d6613.png\" width=\"200\" height=\"194\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f8\/15f\/d34\/9f815fd345db54d067c7ea447c7d6613.png\"\/><\/figure>\n<p>\u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u043c\u0435\u0441\u0442\u0435, \u0432 \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8212; ***<\/p>\n<pre><code class=\"sql\">create procedure BETA as   create table #mytemp (n int, BETA varchar(128))   insert into #mytemp select 1, 'BETA'   select 3 as point, * from #mytemp   select * from tempdb.dbo.sysobjects where name like '%mytemp%' -- *** GO<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/98b\/5c5\/355\/98b5c5355d02cf8c59f2a52cefd8cec2.png\" width=\"637\" height=\"304\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/98b\/5c5\/355\/98b5c5355d02cf8c59f2a52cefd8cec2.png\"\/><\/figure>\n<p>\u0412\u043e\u0442 \u043e\u043d\u0438, \u0434\u0432\u0435 \u043d\u0430\u0448\u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u043c\u0438\u0440\u043d\u043e \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 SQL \u0442\u0430\u043a:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a9a\/7e2\/869\/a9a7e28695da96a362d296fd1556dfed.png\" width=\"469\" height=\"177\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a9a\/7e2\/869\/a9a7e28695da96a362d296fd1556dfed.png\"\/><\/figure>\n<p>\u042f \u043f\u0440\u0438\u0432\u0435\u043b \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0443\u0442 \u043e\u0448\u0438\u0431\u043a\u0430: \u0442\u0430\u0431\u043b\u0438\u0446\u0430 #mytemp \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u041d\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/43f\/7f0\/27b\/43f7f027b343d16d19fe6e49dfc42b2b.png\" width=\"216\" height=\"283\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/43f\/7f0\/27b\/43f7f027b343d16d19fe6e49dfc42b2b.png\"\/><\/figure>\n<p>\u0412 3-\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u043f\u0435\u0447\u0430\u0442\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0430 \u0432 4-\u0439 &#8212; \u0432\u043d\u0435\u0448\u043d\u044f\u044f, \u0438\u0437 ALPHA. \u041f\u043e\u0441\u043b\u0435 drop SQL server \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u0432\u043e\u0441\u0442 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044f, \u043a\u0430\u043a \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0430\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430:<\/p>\n<pre><code class=\"sql\">create procedure BETA as   if object_id('tempdb..#mytemp') is not null     DROP TABLE #mytemp     create table #mytemp (n int, BETA varchar(128))   insert into #mytemp select 1, 'BETA'   select 3 as point, * from #mytemp GO<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0435\u0431\u044f<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/648\/b89\/8ca\/648b898cae276605070d1df23c992459.png\" width=\"639\" height=\"188\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/648\/b89\/8ca\/648b898cae276605070d1df23c992459.png\"\/><\/figure>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0430\u0447\u0430\u043b\u0435, \u0442\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439 ALPHA. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0435 \u0438\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 ALPHA \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0443\u0436\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u0445 ALPHA \u0438 BETA \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u0442\u043e \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e. \u0412\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d.<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/723278\/\"> https:\/\/habr.com\/ru\/post\/723278\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041c\u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u0438\u0434\u0435\u0442\u044c \u0447\u0443\u0436\u043e\u0439 \u043a\u043e\u0434 \u043d\u0430 T-SQL. \u042f \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u044b\u043a \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0435<\/p>\n<pre><code class=\"sql\">drop table #a drop table #b<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u0430\u043c\u0430 \u0441\u0435\u0431\u044f \u043d\u0435 \u0443\u0434\u0430\u043b\u0438\u0442, \u0432\u0438\u0434\u0438\u043c\u043e \u0434\u0443\u043c\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u0440. \u041d\u0443 \u0438\u043b\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 &#171;\u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439&#187;. \u0412\u0434\u0440\u0443\u0433 SQL server \u0437\u0430\u0431\u0443\u0434\u0435\u0442 \u0435\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c? \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u044d\u0442\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0441\u0442\u0440\u0430\u0448\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a SQL server \u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 (\u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043e \u0447\u0435\u043c \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0434\u0430\u043b\u044c\u0448\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0442\u0440\u043e\u0433\u043e \u0432 \u043a\u043e\u043d\u0446\u0435). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u0442\u0435\u043b\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c, \u0442\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u044b, \u0438 \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442 \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443, \u0442\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f.<\/p>\n<p>\u041d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u0430\u043b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0436\u0443\u0442\u043a\u0438\u0439 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d. \u041d\u0435 \u0437\u043d\u0430\u044e, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u043b\u0441\u044f. <\/p>\n<p>\u0412\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435:<\/p>\n<pre><code class=\"sql\">  if object_id('tempdb..#mytemp') is not null     DROP TABLE #mytemp   create table #mytemp (...)<\/code><\/pre>\n<p>\u041c\u043d\u0435 \u043e\u0431\u0438\u0434\u043d\u043e, \u0447\u0442\u043e SQL server \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u0438\u0434\u0438\u043e\u0442\u043e\u043c <em>\u0441\u043e \u0441\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u043c\u0438 \u043e\u0442 \u0432\u044b\u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043b\u044e\u043d\u044f\u043c\u0438<\/em>, \u0438\u0434\u0438\u043e\u0442\u043e\u043c, \u043d\u0435\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u043c \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u043e \u0432\u0430\u0436\u043d\u0435\u0435 \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u043e\u0434 &#8212; \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0431\u043e\u043c\u0431\u0430 \u0441 \u0447\u0430\u0441\u043e\u0432\u044b\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c.<\/p>\n<p>\u041f\u043e\u043a\u0430\u0436\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443:<\/p>\n<pre><code class=\"sql\">create procedure ALPHA as   create table #mytemp (n int, ALPHA varchar(128))   insert into #mytemp select 1, 'ALPHA'   select 1 as point, * from #mytemp   exec BETA   select 2 as point, * from #mytemp GO<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 BETA:<\/p>\n<pre><code class=\"sql\">create procedure BETA as   create table #mytemp (n int, BETA varchar(128))   insert into #mytemp select 1, 'BETA'   select 3 as point, * from #mytemp GO <\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 ALPHA \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u0438\u0434\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u0432\u043e\u0435\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u043c\u0435\u0441\u0442\u0435, \u0432 \u0447\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#8212; ***<\/p>\n<pre><code class=\"sql\">create procedure BETA as   create table #mytemp (n int, BETA varchar(128))   insert into #mytemp select 1, 'BETA'   select 3 as point, * from #mytemp   select * from tempdb.dbo.sysobjects where name like '%mytemp%' -- *** GO<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043e\u0442 \u043e\u043d\u0438, \u0434\u0432\u0435 \u043d\u0430\u0448\u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u043c\u0438\u0440\u043d\u043e \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 SQL \u0442\u0430\u043a:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u042f \u043f\u0440\u0438\u0432\u0435\u043b \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0443\u0442 \u043e\u0448\u0438\u0431\u043a\u0430: \u0442\u0430\u0431\u043b\u0438\u0446\u0430 #mytemp \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u041d\u043e \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0412 3-\u0439 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u043f\u0435\u0447\u0430\u0442\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0430 \u0432 4-\u0439 &#8212; \u0432\u043d\u0435\u0448\u043d\u044f\u044f, \u0438\u0437 ALPHA. \u041f\u043e\u0441\u043b\u0435 drop SQL server \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u0432\u043e\u0441\u0442 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044f, \u043a\u0430\u043a \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0430\u0441 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430:<\/p>\n<pre><code class=\"sql\">create procedure BETA as   if object_id('tempdb..#mytemp') is not null     DROP TABLE #mytemp     create table #mytemp (n int, BETA varchar(128))   insert into #mytemp select 1, 'BETA'   select 3 as point, * from #mytemp GO<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0435\u0431\u044f<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0430\u0447\u0430\u043b\u0435, \u0442\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043e\u0439 ALPHA. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0435 \u0438\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 ALPHA \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0443\u0436\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u0445 ALPHA \u0438 BETA \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u0442\u043e \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e. \u0412\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d.<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/723278\/\"> https:\/\/habr.com\/ru\/post\/723278\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-346943","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=346943"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/346943\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=346943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=346943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=346943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}