My Linux Stuff - Complete Blog For Linux Articles

My Linux Stuff - Complete Blog For Linux Articles

A Website For Complete Linux OS,Step by Step linux Installtion, Linux Tips and Tricks and Linux Stuff and so on... Connect and sharing here....

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

TOP 50 ENGINEERING COLLEGES IN INDIA 2014

This below survey was taken many form many colleges in India. These Top 50 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good.

Top 10 Government Engineering Colleges in India

Top 10 Government Engineering Colleges in India

These Government Engineering Colleges in India are really good for all kind of stuff like Education , research , Placement and New Innovation Ideas etc... But Getting seat in these colleges are heavy competition in students .....

Top 10 Colleges In India 2014

Top 10 Colleges In India 2014

Indian Institute Of Technology Delhi,Indian Institute Of Technology Bombay,Indian Institute Of Technology Kanpur,Indian Institute Of Technology Madras,Indian Institute Of Technology Kharagpur,Indian Institute Of Technology Roorkee,University Of Delhi,Indian Institute Of Technology Guwahati,University Of Calcutta,University Of Mumbai, National Institute Of Technology,Trichy.

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

2014 LATEST SURVEY TOP RANKING ENGINEERING COLLEGES IN INDIA

This below survey was taken many form many colleges in India. These Top 100 Engineering Colleges in India have Good Infrastructure, Good Environment, Educations , Staff, Placement , Research Activities and other Facilities are good. If you want to do Engineering as your dream and try out these colleges

Subscribe Now!

Enter your email address:

Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Sunday, September 13, 2015

How to Select Year Only From Date in SQL

Select Only Year From Date in Oracle Sql

If you want to select only Year in the date below query is the solution for you:


select to_char(REQ_DATE, 'YYYY') as Ye from tbl_pr_data where to_char(REQ_DATE, 'YYYY')='2015';

Note:

REQ_DATE is Coulumn Name
tbl_pr_data is Table Name

In the above select query just i have select the year of 2015 from the table using where Condition.





How to Select Year Only From Date in SQL

Friday, November 18, 2011

SQL Server 2012 Release Candidate is now Available



Building on our announcement at the PASS Summit 2011 in early October, today we are excited to announce the SQL Server 2012 Release Candidate (RC). SQL Server 2012 RC is the first release which is feature complete and represents an exciting milestone for customers and partners looking to experience the full value of SQL Server 2012. 
Over 100K customers have downloaded the SQL Server 2012 Community Technology Previews to date which, through customer feedback, has helped Microsoft deliver a high-quality Release Candidate.

Microsoft SQL Server   

As the foundation of the cloud-ready information platform, SQL Server 2012 will help organizations unlock breakthrough insights across the organization as well quickly build solutions and extend data across on-premises and public cloud backed by mission critical confidence.
The SQL Server 2012 Release Candidate delivers great value to customers:

  • Greater availability. Deliver the required 9s and data protection with AlwaysOn, delivering added functionality over CTP3 that allows customers to experience multiple, readable secondaries for distributed scale of reporting and backup workloads and support for FileTable and FILESTREAM which brings first-class HA to complex data types.
  • Blazing-fast performance. More effectively govern performance in multi-tenancy environments like private cloud. Resource Governor enhancements include support for 64 resource pools, greater CPU usage control, and resource pool affinity for partitioning of physical resources and predictable resource allocation.
  • Rapid data exploration. Empower end users with new insights through rapid data exploration and visualization. Discover new insights at the speed of thought with more feature/functionality in Power View, the highly interactive, familiar browser-based data exploration, visualization, and presentation experience for end users. 
  • Credible, consistent data. In addition to CTP3 functionality delivered for Data Quality Services and Master Data Services, customers can better support heterogeneous data within Data Warehouses through new Change Data Capture (CDC) support for Oracle.
  • Optimized productivity.  Optimize IT and developer productivity across server and cloud with the new SQL Server Data Tools, a unified development experience for database and business intelligence projects, and cloud-ready capabilities within SQL Server Management Studio for snapshot backups to the Windows Azure Platform.  Additionally, SQL Server 2012 offers a new version of Express – LocalDB. SQL Express LocalDB is a lightweight version of Express with all its programmability features, yet runs in user mode with a fast, zero-configuration installation and short list of pre-requisites.  For more information and to try it out, go here.

Today, you have the chance to download, preview and deploy the full marquee capabilities being delivered in SQL Server 2012. RC is a production quality release that includes access to upgrade and migration tools like Upgrade Advisor, Distributed Replay and SQL Server Migration Assistant (SSMA). Upgrade Advisor and Distributed Replay allow you to perform thorough analysis and testing of your current SQL Server applications before upgrading so you know what to expect. You can also use SSMA to automate migrate non-SQL Server databases to SQL Server 2012.

Wednesday, November 16, 2011

Database BackUp and Restore Script

For .Net developer a very common task is to take reguler backup and restore of SQL Server Database. Most of the time developer does that thru UI of Sql Server Management Studio. It is acully nice to know the Scripts which we can run and take backup and restore easily.


       To BackUp :-        
     BACKUP DATABASE [DatabaseName] TO DISK = 'C:\FileName.bak' WITH FORMAT
       To Restore :-
           RESTORE DATABASE [DatabaseName] FROM DISK = 'C:\FileName.bak'


Also when ever you do any database opration thru UI of Sql Server Management Studio you can always have look to the Script behind that opration. Its good practise to look at the script run by Sql Server to do any database realted opration. 

Wednesday, November 9, 2011

SQL Server Interview Questions for 1 Year Experience

1. What is Primary key, unique key and difference between them?
2. What is index? Types of index?
3. What is a stored procedure? Why it is better than inline query?
Hint: Stored Procedure is precompiles and has a execution plan. Hence faster execution.
4. You might be asked to write simple query
5. What is inner join?

6.what is DBMS?
7.what is RDBMS?
8.What is Self Join?
9.what are the types of join?
10.what is diff b/w sql server2005 and 2008?

Sunday, October 30, 2011

Generate SQL Server Connection Strings

This tool will let you generate your SQL Server connection strings - nice and simple.

Click here to create

Monday, March 7, 2011

Difference between stored procedure and functions in SQL Server

1. Functions are compiled and executed at run time.
Stored procedures are stored in parsed and compiled format in the database.

2. Functions cannot affect the state of the database which means we cannot perform insert,delete,update and create operations on the database.
Stored Procedures can affect the state of the database by using insert,delete,update and create operations.

3 Functions are basically used to compute values. We passes some parameters to functions as input and then it performs some operations on the parameter and return output.
Stored procedures are basically used to process the task.

4.Function can not change server environment and our operating system environment.
Stored procedures can change server environment and our operating system environment.

5.Functions can not be invoked from SQL Statements. Execute. SELECT
operating system can be invoked from SQL Statements. Execute. SELECT

6.Functions can run an executable file from SQL SELECT or an action query.
operating system use Execute or Exec to run
 

What is table-space in DB

A tablespace is a logical group of data files in a database. A database typically contains at least one tablespace, and usually two or more. Within the database, the tablespace plays a role similar to that of a folder on the hard drive of a computer.

Tuesday, February 1, 2011

Store Procedure For Forgot Password


USE [ITS_Trainees]
GO
/****** Object:  StoredProcedure [dbo].[VendorForgotPassword]    Script Date: 02/01/2011 15:16:50 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[VendorForgotPassword]
(
@UserName As nvarchar(50)
)
AS
Begin

     SELECT COUNT(*) FROM hbnVendorReg
WHERE UserName=@UserName
IF(@@rowcount = 0)
begin
RAISERROR('UserName does not exists',16,1);
end;
else
 begin
 SELECT r.Password  FROM hbnVendorReg r
 WHERE UserName=@UserName;
 end;


END

Friday, January 28, 2011

Thursday, January 27, 2011

Difference Between Oracle and Sql Server

Platform comparison
SQL Server 2000 only works on Windows-based platforms, including Windows 9x, Windows NT, Windows 2000 and Windows CE.
In comparison with SQL Server 2000, Oracle 9i Database supports all known platforms, including Windows-based platforms, AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, Sun Solaris and so on.

1.Oracle runs on many platforms, SQL on Windows only
2. Oracle includes IFS (Internet File System), Java integration, SQL is more of a pure database
3. Oracle requires client install and setup (Not difficult, but very UNIX-like for Windows users)
4. SQL is #1 in Cost/Performance and overall Performance, although Oracle will refute that
5. Replication is much easier in SQL (I have been at clients where even the Oracle consultant couldn't get it working w/oracle)
6. Failover support in SQL is much, much easier
7. JDBC support is much better in Oracle, although Microsoft is working on it
8. ODBC support in both
9. SQL is ANSI-SQL '92 compliant, making it easier to convert to another ANSI compliant database, theoretically anyway (truth is every database has proprietary extensions). Oracle is generally more proprietary and their main goal is to keep their customers locked-in.
10. SQL natively supports ODBC, OLEDB, XML, XML Query, XML updates. Oracle natively supports proprietary connections, JDBC. Not sure about XML support though.
11. SQL Server is much easier to administrate, with GUI and command- line tools. Most of Oracle is command-line (Back in SQL 6.5 days I had a customer who was so proud that after a day's worth of work he had managed to script his database. I showed him how it was a 3 click operation in SQL ;-)
12. Oracle requires add-ons for transaction monitors, failover, etc. SQL has COM+, uses NT clustering and generally has everything built-in
13. SQL Analysis Services is included (A very powerful OLAP server). For Oracle it is a separate purchase.
14. Oracle will be used especially in large database. But if we use sql server in such a environment, the data processing will become very slower. Oracle database very closely supports Java rather than Sql server.
15. Oracle 7 was RDBMS, i.e it was a relation database and the one's after that i.e. 8 onwards Oracle introduced the concept of OODBMS. Which stands for Object Oriented Database Management Systems. With every major release Oracle has initiated a lot of changes for the better. Like
a. (1) Getting PL/SQL closer to ANSI SQL standards
b. (2) Automatic Management of Undo from 9i onwards
c. (3) Introduction of special Grouping operators for queries
d. (4) ISQL env for easier query processing
e. (5) RAC (I dunno much about it)
f. (6) AS(Application Server, integrated into the database)
16. SQL server GUI is easy to work. SQL serever is easy to maintain. Orcal data procssing is very good compared to SQL server
 

SQL Server 2008 Developer Training Kit Available

The training kit offers the following benefits:
Learn how to build web applications that exploit the unique features and capabilities of SQL Server 2008.
Provides a comprehensive set of presentations, demos and hands-on labs
Designed for web developers who are already familiar with SQL Server application development.
Easy to download and install and works on free editions of SQL Server 2008 and Visual Studio 2008.

Produced by Southworks SRL, a well-known provider of evangelism content, using both existing and new content custom developed for this training kit.
Software Requirements
The following software is not included with the training kit and must be downloaded and installed separately.

SQL Server 2008 Express with Advanced Services (or higher-level SKU)
Microsoft Visual Web Developer 2008 Express (or higher-level SKU)
AdventureWorks 2008 Sample Databases

The training kit is available at the following URL:
SQL Server 2008 Developer Training Kit

SQL Server Short Cuts

Tuesday, January 25, 2011

How SQL Server stores indexes on variable length columns


In the last months I had done a lot of performance tuning workshops, and there is almost the same question: How SQL Server stores indexes on variable length columns? Therefore I thought this would be a great topic for a weblog posting. To examine the concrete storage details of an index defined on a variable length column, I have created the following table and populated it with 80.000 records:
-- Create a new table
CREATE TABLE Customers
(
    CustomerName VARCHAR(255) NOT NULL PRIMARY KEY,
    Filler CHAR(138) NOT NULL
)
GO
-- Insert 80.000 records
DECLARE @i INT = 1
WHILE (@i <= 80000)
BEGIN
    INSERT INTO Customers VALUES
    (
        'CustomerName' + CAST(@i AS VARCHAR),
        'Filler' + CAST(@i AS VARCHAR)
    )
   
    SET @i += 1
END
GO
As you can see I have created the PRIMARY KEY constraint on a VARCHAR(255) column, which is enforced by a UNIQUE CLUSTERED INDEX by SQL Server. In the next step I have retrieved some physical information about the created clustered index by using the DMF sys.dm_db_index_physical_stats:
-- Retrieve physical information about the clustered index
SELECT * FROM sys.dm_db_index_physical_stats
(
    DB_ID('VariableClusteredKeyStructure'),
    OBJECT_ID('Customers'),
    NULL,
    NULL,
    'DETAILED'
)
GO
When you look into the output, you can see that the column min_record_size_in_bytes show you a value of 7 and the column max_record_size_in_bytes shown you the value 28 in the index page. This leads us to the conclusion that the clustered keys are stored as variable length columns inside an index record. So let’s examine an index record on an index page. I’ve used the DBCC IND command to retrieve all pages for our clustered index and stored that output in a little helper table.
-- Create a helper table
CREATE TABLE HelperTable
(
  PageFID TINYINT,
  PagePID INT,  
  IAMFID TINYINT,
  IAMPID INT,
  ObjectID INT,
  IndexID TINYINT,
  PartitionNumber TINYINT,
  PartitionID BIGINT,
  iam_chain_type VARCHAR(30),   
  PageType TINYINT,
  IndexLevel TINYINT,
  NextPageFID TINYINT,
  NextPagePID INT,
  PrevPageFID INT,
  PrevPagePID INT,
  PRIMARY KEY (PageFID, PagePID)
)
GO
-- Write everything in a table for further analysis
INSERT INTO HelperTable EXEC('DBCC IND(VariableClusteredKeyStructure, Customers, 1)')
GO
-- Retrieve the root index page (1 page)
SELECT * FROM HelperTable
WHERE IndexLevel = 2
GO
In my case SQL Server stored the index root page on the page id 458, which I have dumped out through the DBCC PAGEcommand (after enabling the trace-flag 3604 to get the DBCC PAGE output):
DBCC TRACEON (3604)
GO
-- Dump out the root index page
DBCC PAGE(VariableClusteredKeyStructure, 1, 458, 1)
GO
Each slot in the output represents one index record, like:
26 95020000 0100 0100 1b00 43757374 6f6d6572 4e616d65 31333533
Let’s examine those hex values.
  • 26: The first byte represents status bits.
  • 95020000: The next 4 bytes are the child-page-id to which this index record points
  • 0100: The next 2 bytes are the child-file-id to which this index record points
  • 0100: The next 2 bytes are the number of variable length columns
  • 1b00: For each variable length column SQL Server stores a 2 byte entry which points to the offset at which the variable length column ends – it’s the same as when you store variable length columns on a regular data page. In this case we have one variable length column, therefore SQL Server has to store one 2 byte offset – byte offset 27 in this case. This means that the next bytes until the byte offset 27 are part of our variable length column – the clustered key.
  • 43757374 6f6d6572 4e616d65 31333533: The hex value for our clustered key – the column CustomerName
As you can see from this explanation SQL Server stores variable length index columns in the same format as regular variable length columns on data pages. But you have to be aware that there is a slight overhead with this, because you need 2 additional bytes for storing the count of variable length columns and for each variable length column you need 2 bytes in the variable column offset array. Keep this in mind when you are designing your indexes and when you calculate how many index records fits onto one index page. You can download the whole script from here and play around with it.
-Klaus

Related Posts Plugin for WordPress, Blogger...