Posts

Showing posts with the label sql server

Rebuild all indexes in a Database

Image
Manually Rebuild Indexing   Indexes can be rebuilt/reorganize in SQL Server Management Studio using the following steps; 1- In Object Explorer locate the table that holds the intended index and expand it. 2- Expand Indexes. 3- Right-click on the index and click on Rebuild or Reorganize. Rebuild All Table Indexing By Script Try the following script: Exec sp_msforeachtable 'SET QUOTED_IDENTIFIER ON; ALTER INDEX ALL ON ? REBUILD' GO Also I prefer(After a long search) to use the following script, it contains  @fillfactor  determines how much percentage of the space on each leaf-level page is filled with data. DECLARE @TableName VARCHAR ( 255 ) DECLARE @sql NVARCHAR( 500 ) DECLARE @fillfactor INT SET @fillfactor = 80 DECLARE TableCursor CURSOR FOR SELECT QUOTENAME(OBJECT_SCHEMA_NAME([object_id])) + '.' + QUOTENAME(name) AS TableName FROM sys.tables OPEN TableCursor FETCH NEXT FROM TableCursor INTO @TableName WHILE @ @FETCH _STATUS = 0 BEGIN SET

How to Check Index Fragmentation on Indexes in a Database

  Issue SQL Queries taking longer than normal to complete. Cause when a database is frequently updated via INSERT, UPDATE, or DELETE statements, over time these modifications can cause the information in the index to become scattered in the database (fragmented). Fragmentation exists when indexes have pages in which the logical ordering, based on the key value, does not match the physical ordering inside the data file. If database indexes are fragmented, the SQL Server query optimizer may choose a non-optimal execution plan when using an index to resolve a query. Heavily fragmented indexes can degrade query performance and cause your application to respond slowly. Resolution *Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.* The following is a simple query that will list every index on every table in your database, ordered by the

Create Paging Query In the Sql Server

Here we create the Paging in SQL Server  Query here Fetch Only that Record which is Required Query: Select  S.*,SM.Name as shape,CM.Name as Color,PM.Name as Purity,POM.Name As Polish,CUM.Name as Cut,SYM.Name As Symm,Fm.Name as FLS from stock as S Inner join SHAPE_MAS As SM  on SM.SEQ_NO=S.shape_seq inner join COLOR_MAS As CM on CM.SEQ_NO=S.color_seq inner join PURITY_MAS As PM on PM.SEQ_NO=S.PURITY_SEQ inner join POLISH_MAS AS POM on POM.SEQ_NO=S.polish_seq inner join CUT_MAS As CUM on CUM.SEQ_NO=S.cut_seq inner join FLS_MAS As FM on FM.SEQ_NO=S.FLS_Seq inner join SYMM_MAS as SYM on SYM.SEQ_NO=S.SYMM_SEQ    order by S.SEQ_NO Asc OFFSET 25 * (2 - 1) ROWS   FETCH NEXT 25 ROWS ONLY Note:  Here  25 is Page Size You have set Default you Want and 2 is page no it is change every page which record  Example: OFFSET 50 * (3 - 1) ROWS   FETCH NEXT 50 ROWS ONLY Here we set Page Size 50 and page no is 3 This Is useful when we use  the html table use as Grid view and we have easily

Use Sql server With php

            To connect Ms SQL Server  In PhP Note: This is working in the Go-daddy  windows server No setting Required       if  use in the local they are some setting required in Php.ini and add  mssql.dll in  xamp or wamp server. Connect.Php <?php $server = Server Name/IP; $options = array( "UID" => "Username",  "PWD" => "Password",  "Database" => "DbName"); $conn = sqlsrv_connect($server, $options); ?> Note: Can't Close The Connection At Last.                   To Execute the Store Procedure In Php Web services Web_services.php <?php include("connect.php");     // Connection File Include Here     header('Content-Type:application/json;charset=utf8');   header('Access-Control-Allow-Origin: *');   header('Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS');   head

Insert data using jquery

Demo.aspx < html xmlns ="http://www.w3.org/1999/xhtml"> < head id ="Head1" runat ="server">     < title ></ title >     < script type ="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></ script >     < script type ="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></ script >     < script type ="text/javascript">         $(document).ready( function () {             $( '# <% =btnsub.ClientID %> ' ).click( function () {                 $.ajax({                     type: 'POST' ,                     contentType: "application/json; charset=utf-8" ,                     url: 'insertjquery.aspx/Insertmethod' ,                     data: "{'Name':'" + document.getElementById( &