缺少对象或列名,或者对象或列名为空。对于 SELECT INTO 语句,请确保每列均具有名称。对于其他语句,请查找空的别名。不允许使用定义为 "" 或 [] 的别名。请添加名称或单个空格作为别名。 System.Data.SqlClient.SqlException: 缺少对象或列名,或者对象或列名为空。对于 SELECT INTO 语句,请确保每列均具有名称。对于其他语句,请查找空的别名。不允
USE [wise_shop] GO /****** Object: StoredProcedure [dbo].[PhotoAlbum_Del] Script Date: 04/08/2018 22:36:24 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO --根椐ID删除相册图片(含下级) ALTER proc [dbo].[PhotoAlbum_Del] @id varchar(36) as create table #temp( [id] [varchar](36) NOT NULL, [parent_id] [varchar](36) NULL, [url] [varchar](500) NULL, [name] [varchar](200) NOT NULL, [type] [int] NOT NULL, [create_user_id] [varchar](36) NOT NULL, [create_time] [datetime] NOT NULL, [modify_user_id] [varchar](36) NULL, [modify_time] [datetime] NULL, ); with c as ( select * from photo_album where id = @id union all select a.* from photo_album as a join c on a.id = c.parent_id ) insert into #temp select id,parent_id,url,name,type,create_user_id,create_time,modify_user_id,modify_time from c select * from #temp delete photo_album where id in (select id from #temp) drop table #temp go
解决方法:先定议临时表 #temp
,然后再操作