我的表格如Lg-010-a.、lg-010-ac.等,因此,我有一个bc数据库。
我有一个指挥窗口:
drop table from abc where Table_Name like lg-010-%
从Lg-010-开始,所有表格都会下降吗?
我的表格如Lg-010-a.、lg-010-ac.等,因此,我有一个bc数据库。
我有一个指挥窗口:
drop table from abc where Table_Name like lg-010-%
从Lg-010-开始,所有表格都会下降吗?
类似情况:
declare @sql varchar(max)
declare @tablenames varchar(max)
select @tablenames = coalesce(@tablenames + , , ) + Table_Name from INFORMATION_SCHEMA.TABLES
where Table_Name like ( lg-010-% )
set @sql = drop table + @tablenames
exec (@sql)
这就询问了信息表,以检索与你标准相符的表格名称,然后将这些名称加在一起,使之成为一个限定范围的说明。
这一扼杀是列入“Droop”表并处决的。
<代码>Drop table可采用多种压缩表格名称。
(我原先曾有过这种问答表,但一些研究显示,虽然目前情况相当,但信息—— 锡马法方法被预先保证在今后版本中发挥作用。
不幸的是,你能够这样做。 一种办法是:
SELECT DROP TABLE + name FROM sysobjects WHERE name LIKE %lg-010-a% AND [type] IN ( P )
这只是每个表格的DROP TABLE声明的印本,然后可以复制和复制这一产出并投入使用。 你们只能把EXECUTE放在 lo中,而不是放在PRINT上,但我这样做,以便你能够首先看到产出的去向。
我有一个问题,即得到接受的答复没有做任何事情。 我发现,我不得不在守则中添加数据库的序号,以使之发挥作用。 如果您的表格不是一纸空文,那么名人就会这样做。
declare @sql varchar(max)
declare @tablenames varchar(max)
SELECT
@tablenames = COALESCE(@tablenames + , , ) + YourDatabaseName. + Table_Name
FROM
INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = BASE TABLE
AND TABLE_NAME LIKE AP2%
AND (RIGHT(TABLE_NAME, 6) < 201708)
SET @sql = drop table + @tablenames
EXEC (@sql)
GO
Unfortunately you can t do it like that. One way is:
DECLARE @TableName NVARCHAR(128)
SELECT TOP 1 @TableName = TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE lg-010-%
ORDER BY TABLE_NAME ASC
WHILE (@@ROWCOUNT > 0)
BEGIN
PRINT DROP TABLE [ + @TableName + ]
SELECT TOP 1 @TableName = TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE lg-010-%
AND TABLE_NAME > @TableName
ORDER BY TABLE_NAME ASC
END
这只是每个表格的DROP TABLE声明的印本,然后可以复制和复制这一产出并投入使用。 你们只能把EXECUTE放在 lo中,而不是放在PRINT上,但我这样做,以便你能够首先看到产出的去向。
CREATE PROCEDURE dbo.drop_MsSqlTables1 @createDate smalldatetime
AS
declare @flag int =1
declare @tname varchar(50)
declare @sql varchar(max)
select row_number() over (order by name) as num, [dbo].[ + name + ] as table_name into #temp from sys.tables where name like ( EmpInfo_% ) and create_date<@createDate
declare @count int = (select count(*) from #temp)
select * from #temp
while @flag <= @count
begin
set @tname = (select table_name from #temp where num = @flag)
set @sql = drop table + @tname
exec (@sql)
set @flag = @flag+1
end
I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...
In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
Is it possible to use the sqlcmd command to dump table structure the way it can be done with mysqldump?
Hi I have the following SP, however when I use LINQ to SQL it generates 2 multiple recordsets. For my sanity I am trying to fathom out what it is in the stored procedure that is doing this and would ...
I want to create a table in MS SQL Server 2005 to record details of certain system operations. As you can see from the table design below, every column apart from Details is is non nullable. CREATE ...
I love the new DATE datatype in SQL Server 2008, but when I compare a DATE field to a DATETIME field on a linked server (SQL 2005, in this case), like this: DECLARE @MyDate DATE SET @MyDate = CONVERT(...
How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8