-1

我无法从 sql 表中选择超过 1 行。我只能做

Select top 1 * from [table_name] 

或者

Select [pk_table] from [table_name]. 

任何其他命令只会继续处理,并且该表只有大约 300 条记录和 10 列。

表架构:

CREATE TABLE [dbo].[tb1](
    [myid] [int] IDENTITY(1,1) NOT NULL,
    [cl1] [int] NULL,
    [cl2] [int] NULL,
    [cl3] [varchar](5) NOT NULL,
    [cl4] [varchar](5) NULL,
    [cl5] [tinyint] NULL,

CONSTRAINT [PK_tb1_Tbl] PRIMARY KEY CLUSTERED 
(
    [myid] ASC
)
WITH (PAD_INDEX  = OFF, 
STATISTICS_NORECOMPUTE  = OFF, 
IGNORE_DUP_KEY = OFF,     
ALLOW_ROW_LOCKS  = ON, 
ALLOW_PAGE_LOCKS  = ON) 
ON [PRIMARY]
) ON [PRIMARY] 

我不确定是什么导致了这里的问题,因为相同的表模式正在其他数据库中工作。

4

1 回答 1

0

您可以使用以下查询来查找数据库中正在运行的查询:

select
    p.spid
,   right(convert(varchar, 
            dateadd(ms, datediff(ms, P.last_batch, getdate()), '1900-01-01'), 
            121), 12) as 'batch_duration'
,   P.program_name
,   P.hostname
,   P.loginame
from master.dbo.sysprocesses P
where P.spid > 50
and      P.status not in ('background', 'sleeping')
and      P.cmd not in ('AWAITING COMMAND'
                    ,'MIRROR HANDLER'
                    ,'LAZY WRITER'
                    ,'CHECKPOINT SLEEP'
                    ,'RA MANAGER')
order by batch_duration desc
于 2013-11-07T10:47:42.810 回答