Добро пожаловать в форум, Guest >> Войти | Регистрация | Поиск | Правила | | В избранное | Подписаться | ||
Все форумы / Microsoft SQL Server |
![]() ![]() |
Makar4ik Member Откуда: Когда-то были Лужки, а теперь Бордюр-Сити. Сообщений: 2680 |
alter procedure proc2 as begin create table #tab1(id int, id3 int null, id4 int null) insert into #tab1(id) select 3 --insert into #tab1(id, id3) select 4,5 --вызовет ошибку select * from #tab1 --У кого-нибудь есть объяснение, почему работает именно так, и я не могу при этом воткнуть в запись поля id3 и id4? end go alter procedure proc1 as begin create table #tab1(id int, id2 int) insert into #tab1(id,id2) select 1,2 select * from #tab1 exec proc2 select * from #tab1 end go exec proc1 go Собственно, вот... Очень странное поведение. Проверено на 2005-2014. На всех одинаково. |
8 апр 15, 22:59 [17491170] Ответить | Цитировать Сообщить модератору |
Crimean Member Откуда: Сообщений: 13147 |
старая бага. еще и раскладная. |
8 апр 15, 23:12 [17491203] Ответить | Цитировать Сообщить модератору |
invm Member Откуда: Москва Сообщений: 9646 |
Если напишите exec proc2 exec proc1Ошибки не будет. |
||
8 апр 15, 23:41 [17491280] Ответить | Цитировать Сообщить модератору |
Glory Member Откуда: Сообщений: 104751 |
BOL - CREATE TABLE A local temporary table created within a stored procedure or trigger can have the same name as a temporary table that was created before the stored procedure or trigger is called. However, if a query references a temporary table and two temporary tables with the same name exist at that time, it is not defined which table the query is resolved against. Nested stored procedures can also create temporary tables with the same name as a temporary table that was created by the stored procedure that called it. However, for modifications to resolve to the table that was created in the nested procedure, the table must have the same structure, with the same column names, as the table created in the calling procedure. This is shown in the following example. |
9 апр 15, 08:14 [17491759] Ответить | Цитировать Сообщить модератору |
Все форумы / Microsoft SQL Server | ![]() |