[Solved] Convert SQL query to SQL Server [closed]
Use the answer to this question to sort both sides of the comparison alphabetically, and then compare the two sides with an equals operator. solved Convert SQL query to SQL Server [closed]
Use the answer to this question to sort both sides of the comparison alphabetically, and then compare the two sides with an equals operator. solved Convert SQL query to SQL Server [closed]
You are appending mainmenu.tbxSelected whereas I suspect that your intention was to append mainmenu.tbxSelected.Text The former would probably result in a fully qualified typename in your WHERE clause, which would contain commas. As an aside, you should be aware that constructing SQL in this way leaves you potentially open to SQL Injection attacks. If that’s … Read more
It seems for what you are trying to do, that what you need is an UPDATE statement and not an INSERT as you are writing. This seems a much more appropiate query: UPDATE GradeTable SET Grade = @grade, UserID = @UserID, RegDate = @RegDate WHERE StudentID = @StudentID AND CourseID = @CourseID Note that I … Read more
UPDATE whatever_your_table_is_called SET seconddescription = longdescription ,longdescription = seconddescription solved SQL Server, replace value of column A with value of column B, and value of column B with value of column A
This should look more like this: DateTime now = DateTime.Now; DateTime after1month = DateTime.Now.AddMonths(1); SqlCommand cmd = new SqlCommand(“SELECT * FROM TABLE WHERE THEDATE BETWEEN @now AND @after1month”, connection); cmd.Parameters.Add(new SqlParameter(“@now”, System.Data.SqlDbType.DateTime).Value = now); cmd.Parameters.Add(new SqlParameter(“@after1month”, System.Data.SqlDbType.DateTime).Value = after1month); Sometimes you can do it directly on SQL Server side using query: SELECT * FROM TABLE … Read more
Try this code: select id, max(case when seqcnt = -1 then frequency end) [oldfrequency], max(case when seqcnt = 1 then frequency end) [newfrequency] from ( –this subquery will create new column named seqCnt, which will be equal to: — -1 when this is the first seqno — 1 if this is the last seqno — … Read more
If you’re fetching the value into C#, you can use the DateTime.ToString(“dd/mm/yyyy”) on the front end. solved how to display only date in web page [closed]
You were close. You need to move the CASE…END inside the SUM() and drop TRS.DATE from the GROUP BY and ORDER BY. SELECT TRS.ITEM, SUM(CASE WHEN CAST(TRS.DATE AS DATE)=’2022-01-01′ THEN TRS.QTY END) D1Q, SUM(CASE WHEN CAST(TRS.DATE AS DATE)=’2022-01-02′ THEN TRS.QTY END) D2Q, SUM(CASE WHEN CAST(TRS.DATE AS DATE)=’2022-01-03′ THEN TRS.QTY END) D3Q, SUM(CASE WHEN CAST(TRS.DATE AS … Read more
The error is literally telling you the problem: The operating system on this computer or its service pack level does not meet the minimum requirements for SQL server 2016 This error cannot be any more clear; it is telling you you cannot install SQL Server 2016 on the version of Windows you are using: Windows … Read more
SO is not a website when you throw everything here and expected people finish the job for you. Anyway, to give you some hint, I give you a straight suggestion: Select CostGroupId From CostGroups Where CostGroupType = 1 –> Stored these in A collection, like an array: var costGroupsIdArr = ctx.CostGroup.Where(x=>x.CostGroupType == 1).Select(x.CostGroupId).toArray(); Then from … Read more
Never use commas in the FROM clause. Always use proper, explicit JOIN syntax. Then, you cannot nest aggregation functions, so this should be sufficient: SELECT o.ID_DOSSIER, SUM(CASE WHEN ID_TYPE IN (‘0’, ‘1’) THEN TTL * -1 WHEN ID_TYPE IN (‘2’, ‘3’) THEN TTL END) FROM ope o JOIN actor a ON o.ID_ACTION = a.ID_ACTION GROUP … Read more
No need to make thinks more complicated than they need to be… IF OBJECT_ID(‘tempdb..#TestData’, ‘U’) IS NOT NULL DROP TABLE #TestData; CREATE TABLE #TestData ( ID INT NOT NULL, [Year] INT NOT NULL ); INSERT #TestData (ID, Year) VALUES (1, 2010), (1, 2010), (2, 2010), (2, 2011), (3, 2012), (4, 2013), (5, 2014), (5, 2014), … Read more
You basically have the answer written in your question already: IF (NOT EXISTS (SELECT * FROM names WHERE name = @name)) INSERT INTO names (name) values (@name); SELECT id FROM names WHERE name = @name; The only problem is that you haven’t set up your table names to use an IDENTITY column. This means you … Read more
It seems that you are looking for a concat operator as below. SELECT cust_code, cust_name, address_1 + address_2 + address_3 + address_4, telephone FROM a_customer ORDER BY cust_name ASC; You can check the demo here 1 solved How to join 3 columns in SQL Server Management Studio?
This answer has a lot of assumptions as you did not provide any logic for how you want your first table to get to your second. Here are the assumptions I made: A claim/Policy combo share a ID and are prefixed with P for policy and C for claim. The policy-date for a claim and … Read more