[Solved] Get Months between two Date columns
It Solved I used a Loop in SQl that get all months between two dates Then Create report with Matrix get the months above and ID left solved Get Months between two Date columns
It Solved I used a Loop in SQl that get all months between two dates Then Create report with Matrix get the months above and ID left solved Get Months between two Date columns
AddTof1(string s) { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand(“INSERT INTO table1 values(@s)”, connection)) { command.Parameters.AddWithValue(“@s”, s); command.ExecuteNonQuery(); } } } Then you can call this method as; AddTof1(“hello there”); 4 solved How to insert a string into an sql server table via a windows form? [closed]
It would be a lot easier for you to create a cross tabs query. If you can identify the pattern, the dynamic code can be easier to code and there are multiple examples on the internet (and this site). If you don’t know how to create dynamic code, I’d suggest that you stay away from … Read more
You have tagged your question with SQL Server 2016, in SQL Server 2016 there is a new function STRING_SPLIT. In SQL Server 2016 your query should be as simple as: declare @tab table ([user_name] varchar(10),Unit varchar(100)) insert into @tab VALUES (‘ABC’,’1,2′) SELECT t.[user_name] , Value as Unit FROM @tab t CROSS APPLY STRING_SPLIT(t.Unit , ‘,’) … Read more
EDIT From SQL Server 2012 and later you might use the FORMAT function if you want to force a date into a formatted text: https://msdn.microsoft.com/en-us/library/hh213505.aspx With earlier versions you might use something like this: DECLARE @d DATETIME=GETDATE(); DECLARE @TargetFormat VARCHAR(100)=’DD/MM/YYYY’; SELECT CONVERT(VARCHAR(100),@d, CASE @TargetFormat WHEN ‘MM/DD/YYYY’ THEN 101 WHEN ‘DD/MM/YYYY’ THEN 103 –add all formats … Read more
If you are using typed datasets then you have to manually update them if you update your schema. 2 solved Visual Studio ignoring SQL changes in Visual Studio (C#) [closed]
SELECT c.ClientID, c.LastName, c.FirstName, c.MiddleName, CASE WHEN cudf.UserDefinedFieldFormatULink = ’93fb3820-38aa-4655-8aad-a8dce8aede’ THEN cudf.UDF_ReportValue AS ‘DA Status’ WHEN cudf.UserDefinedFieldFormatULink = ‘2144a742-08c5-4c96-b9e4-d6f1f56c76’ THEN cudf.UDF_ReportValue AS ‘FHAP Status’ WHEN cudf.UserDefinedFieldFormatULink = ‘c3d29be9-af58-4241-a02d-9ae9b43ffa’ THEN cudf.UDF_ReportValue AS ‘HCRA Status’ END INTO #Temp FROM Client_Program cp INNER JOIN client c ON c.ulink = cp.clientulink INNER JOIN code_program p ON p.ulink = cp.programulink … Read more
This worked for me: Select * from Addresses Where Addresses.Longitude between -80.33313094482423 and -79.5290690551758 And Addresses.Latitude between 32.6420709033305 and 32.91052662576775 1 solved Returning results within Latitude / Longitude rectagle
Here is one option using an ad-hoc tally/numbers table and a Cross Apply Example Declare @YourTable Table ([Id] int,[Open Date] datetime,[Close Date] datetime) Insert Into @YourTable Values (1,’2019-07-03 16:28:39.497′,’2019-07-04 16:28:39.497′) ,(2,’2019-07-04 15:28:39.497′,’2019-07-05 19:28:39.497′) Select A.* ,TSRange = DateAdd(Minute,N,convert(varchar(16),[Open Date],20)) From @YourTable A Cross Apply ( Select Top (DateDiff(MINUTE,[Open Date],[Close Date])-1) N=Row_Number() Over (Order By (Select … Read more
Introduction Finding the timestamp values between two timestamp records can be a difficult task. However, with the right approach, it can be done quickly and easily. In this article, we will discuss how to find all the timestamp values interval by each minute between two timestamp records. We will discuss the different methods that can … Read more
I did it with the following steps: 1) Created and opened, an SSIS project 2) Added a dataflow task 3) Created a flat file source 4) Created two step transform: 4a) Data Transformation to a dt_decimal 4b) Derived Column with the Expression: decColumn0 / 100 5) Ole DbDestination 1 solved SSIS 2014 issue with currency … Read more
try this, create table #tmp (MR_ID varchar(50),DR_ID int) insert into #tmp VALUES (‘MR_123’, 1),(‘MR_123’, 3),(‘MR_124’, 4),(‘MR_124’, 5) ,(‘MR_124’, 6),(‘MR_125′, 0) declare @DRCol varchar(50) declare @Prefix varchar(20)=’DR_’ ;With CTE as ( select * ,ROW_NUMBER()over(partition by MR_ID order by DR_ID)rn from #tmp ) select top 1 @DRCol=stuff((select ‘,’+'[‘+@Prefix+cast(rn as varchar)+’]’ from cte c1 where c.mr_id=c1.mr_id for xml … Read more
The OP probably already knows this, but here is how to get the answer, disregarding efficiency. First, cards per location, as described in the comments: SELECT locationid, COUNT(DISTINCT cardID) FROM table GROUP BY locationid Next the same thing per state. SELECT substring(locationid, 1, 2) state, COUNT(DISTINCT cardID) FROM table GROUP BY substring(locationid, 1, 2) For … Read more
Sorry @Imrul Kaesh , there is some mistake on the query. I didn’t filter the last 3 months by ItemId. I have updated my query as below, please have a try: WITH Last3Month AS ( SELECT DISTINCT TOP 3 MONTH(IssueDate) AS Mth FROM Issue WHERE ItemId = 452 –Please add this WHERE Clause ORDER BY … Read more
1. Get column name in SQL Server For example: SELECT table_name=sysobjects.name, column_name=syscolumns.name, datatype=systypes.name, length=syscolumns.length FROM sysobjects 2. Example to execute the query in PHP $firstname=”fred”; $lastname=”fox”; $query = sprintf(“SELECT firstname, lastname FROM friends WHERE firstname=”%s” AND lastname=”%s””, mysql_real_escape_string($firstname), mysql_real_escape_string($lastname)); $result = mysql_query($query); solved How to get a column name in SQL Server? [closed]