In this article I will explain some general purpose queries. I think each developer should have knowledge of these queries. These queries are…
Category: Sql Server
SELECT SCH.name AS SchemaName ,OBJ.name AS ObjName ,OBJ.type_desc AS ObjType ,INDX.name AS IndexName ,INDX.type_desc AS IndexType ,PART.partition_number AS PartitionNumber ,PART.rows AS PartitionRows ,STAT.row_count…
USE YourDB GO –get the list of keys in current adtabase select * from sys.symmetric_keys –get the list of certificates in current database…
Some time we have to insert in a foreign key reference table where we have to check subcategory id along with main category…
ALTER function [dbo].[fn_LastChild_Select] ( @ParentId int ) returns int as BEGIN Declare @childid int Declare @Id int SET @Id=@ParentId WHILE EXISTS(select * from…
INSERT INTO dbo.miscDemographics_Relation(miscDemographics_Id,miscDemographics_MasterId,miscDemographics_CreatedDate) SELECT i.miscDemographics_ID,i.miscDemographics_MasterId,GETDATE() FROM inserted i –END WHERE NOT EXISTS (SELECT * FROM dbo.miscDemographics_Relation mrl WHERE i.miscDemographics_ID=mrl.miscDemographics_ID AND ISNULL(i.miscDemographics_MasterId,0)=ISNULL(mrl.miscDemographics_MasterId,0))
ALTER FUNCTION fn_Select_Age_Range ( @dob datetime ) RETURNS nvarchar(200) AS BEGIN declare @year int declare @month int declare @Days int declare @AgeRange nvarchar(200)…