Quantcast
Channel: SqlHints.com » Tips/Tricks
Browsing index pages (16 articles)

Image may be NSFW.
Clik here to view.

How to get all HEAP Tables or Tables without Clustered Index in Sql Server?

A Table that doesn’t have a Clustered Index is referred to as a HEAP Table. We can write a query like below to get all the HEAP Tables or tables that doesn’t have Clustered Index: SELECT T.Name 'HEAP...

View Article


Image may be NSFW.
Clik here to view.

Why the prefix N is used for literal strings in Sql Server?

The Prefix N conveys to the Sql Server that following literal string is of Unicode type. While storing Unicode (i.e. Japanese, Korean, Chinese etc) Characters in NChar, NVarchar or NText columns or...

View Article


Image may be NSFW.
Clik here to view.

PRINT/SELECT Statement messages within WHILE LOOP or BATCH of statement is...

Are you facing the problem where the PRINT/SELECT statements messages are not being displayed like the one’s explained in the below two scenario’s? Let us go through these scenario’s and also see how...

View Article

Image may be NSFW.
Clik here to view.

How to get all the Tables with or without Non-Clustered Indexes in Sql Server?

We can write a query like below to get all the Tables without any Non-Clustered indexes: --List all the Tables with NO Non-Clustered Indexes SELECT Name 'Tables without any Non-Clustered Indexes' FROM...

View Article

Image may be NSFW.
Clik here to view.

How to find all the tables with no indexes at all in Sql Server?

We can write a query like below to get all the Tables in the Database that don’t have any indexes: SELECT Name 'Tables without any Indexes' FROM SYS.tables WHERE...

View Article


Image may be NSFW.
Clik here to view.

How to get all the Tables with or without Primary Key Constraint in Sql Server?

We can write a query like below to get all the Tables with no Primary key constraint: SELECT T.name 'Table without Primary Key' FROM SYS.Tables T WHERE OBJECTPROPERTY(object_id,'TableHasPrimaryKey') =...

View Article

Image may be NSFW.
Clik here to view.

How to get all HEAP Tables or Tables without Clustered Index in Sql Server?

A Table that doesn’t have a Clustered Index is referred to as a HEAP Table. We can write a query like below to get all the HEAP Tables or tables that doesn’t have Clustered Index: SELECT T.Name 'HEAP...

View Article

Image may be NSFW.
Clik here to view.

How to find all the filtered indexes or all the tables having filtered...

We can write a query like below to get the name of all the filtered indexes or all the tables having filtered indexes in Sql Server: SELECT DISTINCT T.Name 'Table Name', I.Name 'Filtered Index Name',...

View Article


Image may be NSFW.
Clik here to view.

How to find all the indexes that have included columns in it and the name of...

We can write a query like below to get the name of all the indexes that have included columns in it and the name of the table to which the index belongs to: SELECT DISTINCT T.Name 'Table Name', I.Name...

View Article


Image may be NSFW.
Clik here to view.

How to get Quarter’s Start and End Date for a given date in Sql Server

We can use a query like below to get Quarter’s Start and End Date for a given date. DECLARE @AnyDate DATETIME SET @AnyDate = GETDATE() SELECT @AnyDate AS 'Input Date', DATEADD(q, DATEDIFF(q, 0,...

View Article

How to get Date Part only from DateTime in Sql Server

Many times we come across a scenario where we need to get Date Part only from DateTime in Sql Server. There are multiple ways of doing this, here I am listing out few of them: 1) Below approach works...

View Article

Image may be NSFW.
Clik here to view.

How to find all tables that have specified column name in Sql Server?

We can use a script like below to find all the tables in the database that have column with specified name in it: SELECT SCHEMA_NAME(schema_id) + '.' + t.name AS 'Table Name' FROM sys.tables t...

View Article

Image may be NSFW.
Clik here to view.

How to find all dependencies of a table in Sql Server?

First of all we shouldn’t use the system stored procedure sp_depends for this as it is not reliable. For more details on sp_depends you can refer to the article sp_depends results are not reliable. For...

View Article


Image may be NSFW.
Clik here to view.

How to find referenced/dependent objects (like Table, Function etc) of a...

First of all we shouldn’t use the system stored procedure sp_depends for this as it is not reliable. For more details on sp_depends you can refer to the article sp_depends results are not reliable. For...

View Article

Image may be NSFW.
Clik here to view.

sp_depends results are not reliable

sp_depends System Stored procedure will give the list of referencing entities for a table/view and list of referenced entities by the stored procedure/view/function. As per MSDN this system stored...

View Article


How to Insert Stored Procedure result into a table in Sql Server?

Today, I was needed to dump the Stored Procedure result into a temp table.  Below example illustrates how this can be achieved: First let us create a stored stored procedure which returns result set:...

View Article
Browsing index pages (16 articles)


Latest Images