best Fifty query for sql server
In this article I will explain some general purpose queries. I think each developer should have […]
How to get all table size and row count from 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 […]
Column level encryption in SQL server 2008r2
USE YourDB GO --get the list of keys in current adtabase select * from sys.symmetric_keys --get […]
Check subcategory id with main category using check constraint
Some time we have to insert in a foreign key reference table where we have to […]
select last child passing by parent id sql server
ALTER function [dbo].[fn_LastChild_Select] ( @ParentId int ) returns int as BEGIN Declare @childid int Declare @Id […]
Insert into where no exist
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 […]
split and compare date in sql server
ALTER FUNCTION fn_Select_Age_Range ( @dob datetime ) RETURNS nvarchar(200) AS BEGIN declare @year int declare @month […]
How to show structure of table
exec sp_help 'tablename'