Amir Mirkamali

امیر میرکمالی

Set database to work in Single User or Multi User Mode

There are two ways :

  1. EXEC sp_dboption 'pubs', 'single user', 'TRUE'
  2. alter database pubs set SINGLE_USER  WITH ROLLBACK IMMEDIATE
To deactive single user mode :
  1. EXEC sp_dboption 'pubs', 'single user', 'FALSE'
  2. 2- alter database pubs set MULTI_USER 

How to Get ALL SQL Server process list?

just run sp_who stored procedure.

Kill all process related to database with T-SQL

CREATE TABLE #TmpWho
(spid INT, ecid INT, status VARCHAR(150), 
loginame VARCHAR(150), hostname VARCHAR(150), 
blk INT, dbname VARCHAR(150), cmd VARCHAR(150))

INSERT INTO #TmpWho
EXEC       sp_who

DECLARE @spid INT     
DECLARE @getspid CURSOR     

SET @getspid = CURSOR FOR     
      SELECT       spid
      FROM      #TmpWho
      WHERE       dbname = 'YOURDBNAME'

OPEN @getspid     

FETCH NEXT FROM @getspid INTO @spid     

WHILE @@FETCH_STATUS = 0 
BEGIN
 KILL @spid --SELECT @spid works fine here
FETCH NEXT FROM @getspid INTO @spid
END
CLOSE @getspid 
DEALLOCATE @getspid 

DROP TABLE #TmpWho

FLV files don't work

If FLV files do not appear in the player and you get 404 error it means that you need to add a mime type for flv files.

add MIME-Type for .FLV extentions with the proper mime-type "flv-application/octet-stream"

Create ASP Net Website Administration Link

  • Create a virtual directory at the root of your default website
  • Name the virtual WebAdmin
  • Set the Path of the Virtual Directory to "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\ASP.NETWebAdminFiles" where 50215 is the appropriate build version for your installed .NET 2.0 framework.
  • After the Virtual Directory has been created, right click on the Virtual Directory and got to properties.  Select the ASP.NET tab and make sure the ASP.NET version is set to a 2.0 version.
  • Open a browser and browse to the following url:
    http://localhost/webadmin/default.aspx?applicationPhysicalPath=D:\wwwroot\timetracker\&applicationUrl=/Timetracker
  • Make sure to change the applicationPhysicalPath and applicationUrl querystring parameters to match whatever they are on your system.

Empty All tables content in SQL Server

DECLARE @tableCatalog VARCHAR (1024) , 

@tableSchema VARCHAR (1024), @tableName VARCHAR (1024), @tableType VARCHAR (1024)
DECLARE cursorTemp CURSOR FOR
SELECT * FROM INFORMATION_SCHEMA.TABLES
OPEN cursorTemp
FETCH cursorTemp INTO @tableCatalog, @tableSchema, @tableName, @tableType


-- start the main processing loop.
WHILE @@Fetch_Status = 0
BEGIN
    EXEC (' ALTER TABLE '+@tableName+' NOCHECK CONSTRAINT ALL;' +
    ' DELETE FROM '+ @tableName +';'+
    ' ALTER TABLE '+@tableName+' CHECK CONSTRAINT ALL ') 
    FETCH cursorTemp INTO @tableCatalog, @tableSchema, @tableName, @tableType
END

CLOSE cursorTemp
DEALLOCATE cursorTemp

Stored procedure Vs User Functions

  1. in functions u cant use DDL , DML smts (like Insert and Update) which is possible in SPs
  2. U can use function output in select smts (like Select fnTest(), a from test a)
  3. U can use the function output in joins (like test a LEFT OUTER JOIN fnTest() b )
  4. Sp can retun multiple resultset, function can return only one resultset
  5. Function can accept less parmeter than procedure
  6. Function can not return XML output
  7. Stored Procedures are basically compiled which results in faster execution.
  8. Functions must always return a value (either a scalar value or a table). Stored procedures may return a scalar value, a table value or nothing at all.
  9. Stored procedures are called independently, using the EXEC command, while functions are called from within another SQL statement.
  10. Stored procedure allow you to enhance application security by granting users and applications permission to use stored procedures

Set nowrap property in css

You change wrap property with white-space property in css.
normal : Default. White-space is ignored by the browser
pre : White-space is preserved by the browser. Acts like the pre tag in HTML
nowrap : The text will never wrap, it continues