This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10356|Reply: 0

[Source] sql notes from recent days

[Copy link]
Posted on 2/9/2015 4:09:55 PM | | |
select * from sgk where id =1;
exec sp_spaceused sgk;

--JIU:423771079  156005274

--rows
--428700186  

select top 10 * from sgk order by id desc
--mohuchaxun
select * from sgk where name1 like '%123%'
select * from sgk where email like '%123%'
--jingquechaxun
select * from sgk where name1 ='123'
--lianhechax
select * from sgk where name1 like '%123%' or email like '%123%'

select * from sgk where name1 = '123' or email = '123@qq.com'

--Enable AWE for SQL SERVER and set the maximum memory to 8G
sp_configure "show advanced options", 1
RECONFIGURE WITH OVERRIDE
GO
sp_configure "awe enabled", 1
RECONFIGURE WITH OVERRIDE
GO
sp_configure "max server memory", 8120
RECONFIGURE WITH OVERRIDE
GO
RECONFIGURE
GO



select  top 1000000 *  into testtable from  sgk


sp_attach_single_file_db @dbname=  'QunInfo1' ,
@physname = 'E:\BaiduYunDownload\QQ Database\QQ Database\QunData\QunInfo1_Data.MDF'

sp_attach_single_file_db @dbname=  'QQ_GroupData1' ,
@physname = 'E:\BaiduYunDownload\QQ Database\QQ Database\QunData\GroupData1_Data.MDF'


insert into QQ_GroupData.dbo.Group101
select * from Group1


insert  Group1
select * from(
select QQNum,Nick,Age,Gender,Auth,QunNum from Group2
union
select QQNum,Nick,Age,Gender,Auth,QunNum from Group3
union
select QQNum,Nick,Age,Gender,Auth,QunNum from Group4
)t



DECLARE @i int  
Set @i = 2
--Start looping inserting data
WHILE @i < 3 and @i>1
BEGIN   
insert  Group1
select * from(
select QQNum,Nick,Age,Gender,Auth,QunNum from Group+@i
)t
Set @i =@i +1
END   
select count(*) from Group1
--760440
truncate table group1

select * from Group100

select * from QunList2

select 'insert into group1 select * from '+DB_NAME()+'dbo.' +o.name+'; ' from sys.objects o where o.name like '%group%';
select 'insert into group1 select * from '+o.name+'; ' from sys.objects o where o.name like '%group%' and o.type='U';
select 'drop table '+o.name+'; ' from sys.objects o where o.name like '%group%' and o.type='U';



select * from Group1 where QQNum='123'
DBCC FREEPROCCACHE
DBCC ShrinkDatabase(QQ_GroupData1)






Previous:Ordinary SQL statements can be executed with exec
Next:After MSSQL deletes a large number of table records, the database capacity does not decrease
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com