Skip to main content

Posts

How to see current executing query

There are various way in sql server to see current executing query .. Using DMV          select * from sys . sysprocesses where status = 'Running' select * from sys.dm_exec_Requests where status=' Running select * from sys.dm_exec_sessions where status=' Running ' Using DBCC a.        DBCC opentran b.       DBCC inputbuffer ( SP_ID ) SSMS GUI using Activity Monitor. DBCC opentran DBCC inputbuffer ( SP_ID ) CREATE TABLE T1 ( Col1 int , Col2 char ( 3 )); GO BEGIN TRAN INSERT INTO T1 VALUES ( 101 , 'abc' ); GO DBCC OPENTRAN ; ROLLBACK TRAN ; GO DROP TABLE T1 ; GO

Dam Dam Lake Gurgaon @ 13.03.13

"UP and Down of ECG Line shows we are live and straight line shows we are no more " That's very true and  popular thought for life . In Day to Day life we face lots of challenges and situations like up and down, We should to face these with ease. Friends Since few months i was also facing some new problems and challenges of life but by god grace problems are also being short outs and life going forward and cool with family and friends by learning learning learning ..  The best thing about brave person is how he is managing life in such situation. Every human has different aspects for managing situation but my thought is Stay cool. I want to share about last month trip which helped me to bring myself cool from worth situation. I went for outing after 6 months with our boss colleague (Hasan Sir, Dev Sir and Pratyush Sir). Actually We planned to attend mirage of one of colleague Dharmendra and additionally we planned to visit this Place  The place was DADAM

DATALENGTH for Text Data Type

Last Friday i was working on our one of legacy application. And we were required for finding length from text field but when i tried below sql.. select top 2 circuit_id , len ( prov_config ) from config sql server given error Msg 8116, Level 16, State 1, Line 4 Argument data type text is invalid for argument 1 of len function. When I tried to convert into varchar then result was completely different than actual. select top 2 circuit_id , len ( cast ( prov_config as varchar )), prov_config from config Finally I tried Datalength which I got from SQLAuthority. select top 2 circuit_id , Datalength ( prov_config ), prov_config from config I Solved my problem using Datalength but the question still running in my mind why there is two function for finding Length LEN for char and DATALENGTH for Text and why the errors comes Argument data type text is invalid for argument 1 of len function. . Thanks for reading  Suman

How to find Windows uptime

Sometimes if we require to find the windows uptime or when last booted our system we can do by net statistics server.... Just open cmd prompt from Run. and type  net statistics server . Thanks Suman

Excel Shortcuts

Very Useful Keyboard Shortcuts 1.   To format any selected object , press ctrl+1 2.   To insert current date , press ctrl+; 3.   To insert current time , press ctrl+shift+; 4.   To autosum selected cells , press alt + = 5.   To see the suggest drop-down in a cell , press alt + down arrow 6.   To enter multiple lines in a cell , press alt+enter 7.   To insert a new sheet , press shift + F11 8.   To edit active cell , press F2 (places cursor in the end) 9.   To hide current row , press ctrl+9 10.   To hide current column , press ctrl+0 11.   To unhide rows in selected range , press ctrl+shift+9 12.   To unhide columns in selected range , press ctrl+shift+0 13.   To recalculate formulas , press F9 14.   To apply outline border around selected cells , press ctrl+shift+7 15.   To open the macros dialog box , press alt+F8 16.   To copy value from above cell , press ctrl+’ 17.   To format current cell with comma formats , press ctrl+shift+1 18.   To go to the next work

Data purging and Archival from VLDB

How to delete Records from a Very Large Tables ? If we have to delete a large records based on some conditions like year wise - month wise from very large table and our SLA is without degrading system performance then we will come into problem .We can't use TRUNCATE TABLE and we may run out of disk space and then DELETE query fails and nothing is deleted. The Real-Problem (from SQL Bible) A DELETE executes as a transaction where it will not commit until the last record is deleted. DELETE physically removes rows one at a time and records each deleted row in the transaction log. If the number of records in a table is small, a straight out DELETE is fine, however, with a large table the DELETE will cause the transaction log to grow. When this happens the system IO performance is degraded. Also, the table will be locked which will affect the application. The person executing the DELETE query will usually panic because what seems to be a simple task takes a long time an

Difference between Logins and Users

What is Difference between Logins and Users. Logins and Users are complete different things in  Microsoft SQL Server.  Many of us assumes that they are the same thing, it can get a little confusing.  The basic difference is login is created on instance level and when a login is given access to a particular database then it's call a user for that database. In simple every database user there should be a login. Logins are created at the database server instance level, while uses are created at the database level.  CREATE  LOGIN TestLogin  WITH  PASSWORD  =  'I4india@2012' select * from sys.syslogins where name='TestLogin' use company CREATE  USER  TestUser  FOR  LOGIN TestLogin select * from sysusers where name=' TestUser '   There are two main categories of logins: SQL Server authenticated logins and Windows authenticated logins. I will usually refer to these using the shorter names of SQL logins and Windows logins.