Find missing months in SQL

So this post remains unanswered and not useful Finding missing month from my table This link Get Missing Month from table requires a lookup table… which is not my first choice. I have a table with Financial Periods, and a reference number. Each reference numbers has a series of financial periods which may start anywhere,… Read More Find missing months in SQL

SQL SERVER INVALID TYPE

I have a message error "Invalid int argument data type for substring function argument 1." I don’t understand why ! UPDATE DBO.NUMBER SET NUMBER = 22675442455 WHERE SUBSTRING(ID,1,2) NOT IN (’67’,’68’) Thanks for your help ! >Solution : SUBSTRING required first argument as STRING, so simply convert it to VARCHAR. UPDATE DBO.NUMBER SET NUMBER =… Read More SQL SERVER INVALID TYPE

Conversion failed when converting the varchar value 'SELECT ISDATE(@P_Input)' to data type int

ALTER FUNCTION[dbo].[DateValidation] ( @P_Input NVARCHAR(55) ) RETURNS NVARCHAR(55) AS BEGIN DECLARE @V_Results DATE DECLARE @V_Result INT DECLARE @V_ERROR NVARCHAR(MAX) set @V_Result=’SELECT ISDATE(@P_Input)’ IF @V_Result=1 BEGIN SET @V_Results=’SELECT CONVERT(P_Input,getDate(),2)’ RETURN @V_Results END SET @V_ERROR =’NOT IN DATE FORMAT’ RETURN @V_ERROR END GO >Solution : First of all you are setting variable @V_Result with string (Command). If… Read More Conversion failed when converting the varchar value 'SELECT ISDATE(@P_Input)' to data type int

SQL: How to parse a string only where certain character patterns exist

I’m aware of using various functions like CHARINDEX and PATINDEX, but only for a single "spot" in a string. What I’m needing to do is parse out the characters of a string that exist between a < and >. For example: <ul><li>Good afternoon,<br /><br />Please see the NDC number listed on the attached delivery ticket.<br… Read More SQL: How to parse a string only where certain character patterns exist

Select from parent-children xml content

I have been looking for solution for selecting parent-child relation from table [Group] which contains a xml column. [Group] table has the following structure: ID – int Content – xml There is xml data – parent-child relation in column Content <root> <person name="John"> <device name="notebook" /> <device name="xbox" /> </person> <person name="Jane"> <device name="TV" />… Read More Select from parent-children xml content