Monday, 27 April 2015

How to Create table in sql server ?


Create table command in sql:-

CREATE TABLE [dbo].[Tax](
      [TaxID] [int] NOT NULL,
      [TaxName] [nchar](50) NULL,
      [TaxRule] Numeric(18,2)) NULL,
      [Description] [text] NULL,
      [FinancialYear] [nvarchar](255) NULL,
      [TaxStatus] [nchar](10) NULL,
 CONSTRAINT [PK_Tax] PRIMARY KEY CLUSTERED
(
      [TaxID] ASC
)
)

Insert query in sql

Syntex
Insert into tableName(clo1,clo2,col3) Values(value1.value2,value3)

Example

INSERT INTO [dbo].[Tax] ([TaxID], [TaxName], [TaxRule], [Description], [FinancialYear], [TaxStatus])
 VALUES (1, 'Service Tax',CAST(2.50 AS Numeric(18, 2)),'As par Govt. of India', 'March 2012-13', 'Active')
INSERT INTO [dbo].[Tax] ([TaxID], [TaxName], [TaxRule], [Description], [FinancialYear], [TaxStatus])
 VALUES (2, 'Transportation Tax',CAST(12.50 AS Numeric(18, 2)),'As par Govt. of India', 'March 2012-13', 'InActive')
INSERT INTO [dbo].[Tax] ([TaxID], [TaxName], [TaxRule], [Description], [FinancialYear], [TaxStatus])
 VALUES (3, 'VAT',CAST(12.50 AS Numeric(18, 2)),'As par Govt. of India', 'March 2012-13', 'Active')
INSERT INTO [dbo].[Tax] ([TaxID], [TaxName], [TaxRule], [Description], [FinancialYear],
 [TaxStatus])
 VALUES (4, 'sessional Tax',CAST(1.50 AS Numeric(18, 2)),'As par Govt. of India', 'March 2012-13', 'Active')

Result after runing the query















Delete query with where clause it will delete only conditional row





No comments:

Post a Comment