T-SQL user guide
==================== Calcul d’ un max d’ un champs ====================
Unicode = 2 caractères
SQL Server also has a DATALENGTH() function. This function can be used on all data types
(Text, NText or Image data types) in your table.
SELECT a020, DATALENGTH(a020) FROM dbo.notices Ordre décroissant : SELECT a020, DATALENGTH(a020) FROM dbo.notices ORDER BY 2 DESC le maximun : SELECT TOP 1 a020, DATALENGTH(a020) FROM dbo.notices ORDER BY 2 DESC
=================================================================
Merge de tables SQL / As for performance, so long as the id field(s) in tablea (the big table)
are indexed, you should be fine.
===================================================
begin tran; delete from Source1 where exists (select 1 from Depouillement where Depouillement.isn=Source1.isn); insert into Depouillement select * from source1; commit tran; option 2: begin tran; delete from tablea where exists (select 1 from tableb where tablea.id=tableb.id); insert into tablea select * from tableb; commit tran; option 3: begin tran; delete from tableb where exists (select 1 from tablea where tablea.id=tableb.id); insert into tablea select * from tableb; commit tran;
============== Incrémenter un champ type ID =================
DECLARE @id int set @id = 0 UPDATE A230 SET id = @id, @id = @id + 1
======================= timestamp binary data sql =====
select convert(int, timestamp) as version from products select convert(bigint, timestamp) as version from products
===================== How to empty Log files ===============
backup log [wahda] with truncate_only go DBCC SHRINKDATABASE ([wahda], 10, TRUNCATEONLY) go
SECURISER BASE SQL + ACCES INETPUB (Application Web)
=============================================
if not exists (select * from master.dbo.syslogins where loginname = N'WidgetStoreDAL') exec sp_addlogin N'WidgetStoreDAL', N'password', N'WidgetStore', N'us_english' GO if not exists (select * from dbo.sysusers where name = N'WidgetStoreDAL') EXEC sp_grantdbaccess N'WidgetStoreDAL', N'WidgetStoreDAL' GO exec sp_addrolemember N'db_denydatareader', N'WidgetStoreDAL' GO exec sp_addrolemember N'db_denydatawriter', N'WidgetStoreDAL' GO ======================================================================= if not exists (select * from master.dbo.syslogins where loginname = N'DOTNET2010\ASPNET') exec sp_grantlogin N'DOTNET2010\ASPNET' exec sp_defaultdb N'DOTNET2010\ASPNET', N'WidgetStore' exec sp_defaultlanguage N'DOTNET2010\ASPNET', N'us_english' GO if not exists (select * from dbo.sysusers where name = N'DOTNET2010\ASPNET') EXEC sp_grantdbaccess N'DOTNET2010\ASPNET', N'DOTNET2010\ASPNET' GO exec sp_addrolemember N'db_denydatareader', N'DOTNET2010\ASPNET' GO exec sp_addrolemember N'db_denydatawriter', N'DOTNET2010\ASPNET' GO