Skip to main content

Posts

Showing posts from May, 2016

How to display simple jquery loader/spinner using ajax?

Showing loading image indicator when ajax calling and also loading display off when ajax get response. <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> $(document).ready(function(){     $(document).ajaxStart(function(){         $("#divLoadingd").css("display", "block");     });     $(document).ajaxComplete(function(){         $("#divLoadingd").css("display", "none");     });     $("button").click(function(){         $("#txt").load("demo_ajax_load.asp");     }); }); </script> </head> <body> <div id="txt"><h2>Let AJAX change this text</h2></div> <button>Ajax Call</button> <div id="divLoadingd" style="display:none;width:69px;height:89px;bord...

How to get table detail structure in SQL Server

We  select a table name in the query window of SQL Server Management Studio and press ALT + F1. It will display the details of that table. beside's that We can get Table details with execute " SP_HELP" command: SP_HELP TableName

Computed Columns into Table -Sql Server

        A computed column is a virtual column that is not physically stored in the table, unless the column is marked PERSISTED. A computed column expression can use data from other columns to calculate a value for the column to which it belongs. You can specify an expression for a computed column in in SQL Server 2016 by using SQL Server Management Studio or Transact-SQL CREATE TABLE dbo.Products  (     ProductID int IDENTITY (1,1) NOT NULL   , QtyAvailable smallint   , UnitPrice money   , InventoryValue AS QtyAvailable * UnitPrice ); -- Insert values into the table. INSERT INTO dbo.Products (QtyAvailable, UnitPrice)   VALUES (25, 2.00), (10, 1.5); -- Display the rows in the table. SELECT * FROM dbo.Products;   To add a new computed column to an  existing table ALTER TABLE dbo.Products ADD RetailValue AS (QtyAvailable * UnitPrice * 1.35); To Change an existing column to a computed column ALT...

Delete column from table

When we delete a column from a table, it and all the data it contains are deleted from the database. This action cannot be undone. We cannot delete a column that has a CHECK constraint. You must first delete the constraint.we cannot delete a column that has PRIMARY KEY or FOREIGN KEY constraints or other dependencies except when using the Table Designer. When using Object Explorer or Transact-SQL, we must first remove all dependencies on the column. ALTER TABLE dbo.TableName DROP COLUMN column_b ;

Rename Columns In SQL Server

To rename a column using Object Explorer In  Object Explorer , connect to an instance of Database Engine. In  Object Explorer , right-click the table in which you want to rename columns and choose  Rename . Type a new column name. To rename a column using Table Designer In  Object Explorer , right-click the table to which you want to rename columns and choose  Design . Under  Column Name , select the name you want to change and type a new one. On the  File  menu, click  Save   table name . To rename a column using T-SQL EXEC sp_rename 'TableName.OldColumnName', 'NewColumnName', 'COLUMN'; EXEC sp_rename 'Sales.Employee.EployeeJobId', 'JobID', 'COLUMN';

To modify the data type of a column

Modifying the data type of a column that already contains data can result in the permanent loss of data when the existing data is converted to the new type. In addition, code and applications that depend on the modified column may fail. These include queries, views, stored procedures, user-defined functions, and client applications.  Note that these failures will cascade. For example, a stored procedure that calls a user-defined function that depends on the modified column may fail. Carefully consider any changes you want to make to a column before making it. CREATE TABLE dob.Table_Example (column_a INT ) ; GO INSERT INTO dbo. Table_Example (column_a) VALUES (10) ; GO ALTER TABLE dbo. Table_Example ALTER COLUMN column_a DECIMAL (5, 2) ; GO

Sql Server Functions

Function  Function is a database object in Sql Server. Basically it is a set of sql statements that accepts only input arameters, perform actions and return the result. Function can return only single value or a table. We can’t use function to Insert, Update, Delete records in the database table(s).Generally two types of functions are available in sql server these are System Defined Function , another is User defined Funtion.  Types of Function System Defined Function SDF are built in function in Sql Server. User defined function are two types are Scalar Function and Aggregate Function. These functions are defined by Sql Server for different purpose.                    01. Scalar Function                     Scalar functions operates on a single value and returns a single value. Below is the list of some                ...