Skip to main content

Posts

Get Time zone in sql server

Do you want to get timezone in sql server Here is the script DECLARE @TimeZone VARCHAR ( 50 ) EXEC MASTER .dbo. xp_regread 'HKEY_LOCAL_MACHINE' , 'SYSTEM\CurrentControlSet\Control\TimeZoneInformation' , 'TimeZoneKeyName ' , @TimeZone OUT SELECT @TimeZone

Solution to find the largest unique string in given string

There is a problem like we need to find the largest distinct string in a given string. For example, there is a string - ababa and the largest distinct string in it such that no two adjacent characters are same is "ababa" Second example - we are given string - aaaaac so largest distinct string is - "ca" How to find the solution for this Solution : We need to create a vertical array for this - character by character Like a string is given - "abccdderteerveedsseqwsaxztybb" So we will create a vertical array as below - a b cc  d   d   e   r   t   ee    r    v    ee     d     ss      e      q      w      s      a      x      z      t      y      bb Whenever there is a repeated word we need to put that in same line else to...

Enable Audit Record in Sql server

Command in Sql Server Master database USE MASTER GO CREATE SERVER AUDIT audit_test                                           TO FILE (FILEPATH = 'G:\') GO CREATE SERVER AUDIT SPECIFICATION audit_test_spec       FOR SERVER AUDIT [audit_test] ADD (FAILED_LOGIN_GROUP), ADD (SUCCESSFUL_LOGIN_GROUP) WITH (STATE=ON) GO Now check in Security-> Audit -> Audit log

How to find the active SQL connections and kill them

Find Active connections in sql server select     db_name(dbid) as [Database Name],     count(dbid) as [No Of Connections],     loginame as [Login Name] from     sys.sysprocesses where     dbid > 0 group by     dbid, loginame How to kill a SQL connection set nocount on declare @databasename varchar(100) declare @query varchar(max) set @query = '' set @databasename = 'xxx' if db_id(@databasename) < 4 begin print 'system database connection cannot be killeed' return end select @query=coalesce(@query,',' )+'kill '+convert(varchar, spid)+ '; ' from master..sysprocesses where dbid=db_id(@databasename) if len(@query) > 0 begin print @query exec(@query) end Thanks

New Smartphone with 12GB RAM, 1TB storage unveiled

Here is the News -- Turing Robotics Industries (TRI) has unveiled its latest smartphone - the Turing Phone Cadenza. It comes with 'Voice On' technology which enables the smartphone to be switched On/Off using voice commands. Users can also use these voice commands for biometric authentication. The Turing Phone Cadenza features a 5.8-inch Quad HD display of 1440x2560 pixel resolution. It is powered by not one, but two Qualcomm Snapdragon 830 (even though the same hasn't been officially announced) CPUs paired with a an astonishing 12GB of RAM and 1TB of internal storage. The storage can be further expanded up to 500GB by installing a microSD card. The Cadenza runs Turing's own Swordfish OS with deep learning Artificial Intelligence (AI) features a 60MP rear camera with IMAX 6K recording facility and a 20MP dual-front camera. Users can install up to 4 sim cards in the smartphone and it houses a huge 100Wh battery with graphene and hydrogen fuel cells.  In related ne...

How to put delay before doing an operation in WPF

Here is the code : The call to Thread.Sleep is blocking the UI thread. You need to wait asynchronously. Method 1: use a DispatcherTimer tbkLabel . Text = "two seconds delay" ; var timer = new DispatcherTimer { Interval = TimeSpan . FromSeconds ( 2 ) }; timer . Start (); timer . Tick += ( sender , args ) => { timer . Stop (); var page = new Page2 (); page . Show (); }; Method 2: use Task.Delay tbkLabel . Text = "two seconds delay" ; Task . Delay ( 2000 ). ContinueWith ( _ => { var page = new Page2 (); page . Show (); } ); Method 3: The .NET 4.5 way, use async/await // we need to add the async keyword to the method signature public async void TheEnclosingMethod () { tbkLabel . Text = "two seconds delay" ; await Task . Delay ( 2000 ); var page = new Page2 (); page . Show (); }