Forum Widgets
Latest Discussions
Error when trying to create a Trigger
Hi I am trying to create a trigger so when a value changes from null to a value it copies the value into another field. However, I am getting errors on the basic code like BEFORE. Any ideas why? Thanks AaronSolvedAjcbutlerSeikiApr 11, 2025Copper Contributor82Views0likes4CommentsHow to create a view with unique record based on date
I have an EMPLOYEE table that looks like this: EmployeeID,Name,PositionID,HireDate,PositionStatus E001,Chelsey,P123,2013-11-23,Terminated E001,Chelsey,P234,2019-03-13,Active E002,Mike,P345,2014-03-23,Terminated E002,Mike,P345,2021-10-13,Terminated E003,James,P543,2015-01-12,Active E004,Samantha,P895,2018-12-13,Terminated E004,Samantha,P430,2020-05-21,Terminated E004,Samantha,P945,2022-06-16,Active E005,Kayla,P459,2023-03-13,Terminated As you can see, the EmployeeID can have duplicate. The reason for this is, there's a secondary ID called PositionID, which essentially describes the employee's role. For example, whenever an employee gets promoted, or moves to a different department, a new record will be created for them with the same EmployeeID but a different PositionID. When that happens, the Position Status of the older role gets set to Terminated, and the new one gets set to Active. The HireDate represents the date teh employee started working in that role. I would like to create a VIEW to filter this to have only the unique employees, based on the HireDate. If there are multiple records for the same employee, I want the view to show only the record with the most recent HireDate. The resulting table should look like this: What's the best way to go about this?SolvedSach-SGApr 01, 2025Copper Contributor59Views0likes2CommentsRounding issue - expected or bug?
Hello, we use SQL Server 2019 and we got some unexpected rounding issues. See example: It is only example with numbers, in our situation there were sub selects with data types: 0.4399 = decimal(20,4) 33.00 = decimal(20,2) 1 = smallint. My question is, why in first and fifth selects is result only with 2 decimal and not 4 based on first number with data type decimal (20,4)? I have tested it with latest cumulative update. Thank you for your answer. PavolSolvedPavolSApr 01, 2025Copper Contributor83Views0likes2CommentsChange the timezone for date/time - Arizona
Hello, I am in Arizona with no daylight saving. The SQL database I am pulling date/time codes has nightmarish Epoch (INT) fields for the date/time fields and it's in Eastern Time Zone. I figured out how to convert the code to date / time. However, HOW do I change the Eastern Time ZONE to either Pacific (Spring/Summer) or Mountain (Fall/Winter)?? Unfortunately, there is no Arizona Time Zone for MS SQL. Convert(varchar,DATEADD(MILLISECOND, CAST(RIGHT(Completed_Date, 3) AS INT) - DATEDIFF(MILLISECOND,GETDATE(),GETUTCDATE()), DATEADD(SECOND, CAST(LEFT(Completed_Date, 10) AS INT), '1970-01-01')),22)as 'PBI Completed Date' Thank you!SolvedHopeisgood1Mar 27, 2025Copper Contributor186Views0likes16CommentsSQL Query
Hi All, I have 2 tables ConfigurationTable and Data table. I require combine value like below output Source tables: Target Output: Sql Scripts: CREATE TABLE CONFIGTABLE(Productcode VARCHAR(10), Linkedvalue VARCHAR(10)) INSERT INTO CONFIGTABLE VALUES ('A', 'PEN') ,('C', 'PENCIL') ,('B', 'BOOK') ,('M', 'MOUSE') CREATE TABLE DATATABLE (FIELDVALUE VARCHAR(50), ORDERID INT,NAME VARCHAR(20)) INSERT INTO DATATABLE VALUES ('321', 9, 'COMPUTER') ,('THIS PEN IS', 1, 'A') ,('Country', 5, 'BOOK') ,('Great village in a', 4, 'B') ,('MINE', 2, 'PEN')SolvedBADDULAMar 24, 2025Copper Contributor54Views0likes2CommentsStrange behavior of MSSQL Listener name + port
Hello, everyone. We are running MSSQL 2022, we have 2 listener and port, said LSNA with port 1434, LSNB with port 1435. The connection is no problem. But strange is that it can also go into DB with LSNA,1435 and LSNB,1434 which do not exist, it will go to DB according to port but not listener+port. Anyone can give advise to me on this? Thank you very much in advance.Solvedchanrky1202Mar 20, 2025Copper Contributor123Views0likes3CommentsTable
Hello everyone, I have a problem. Our products are dimension-dependent (width / height) and the prices are stored in a table [Costinformation]. The grid table is in the Pricetable column. Rows are separated with CRLF and the individual columns with Tab. Table [Costinformation] Mandant Code Text Category Pricetable 1 4711 Product Table 1 Window 1 4712 Product Table 2 Door Example Pricetable-Column W / H 100 200 300 400 100 10,00 20,00 30,00 40,00 200 20,00 30,00 40,00 50,00 300 30,00 40,00 50,00 60,00 400 40,00 50,00 60,00 70,00 Now it is so that there are always price adjustments. In 100% of cases, this is in percentage terms. This means that the prices in the grid table have to be extrapolated. I need a solution so that I no longer have to do this manually. Can it be done directly via an SQL statement? Example: Product Table 1 --> price + 5% Produkt Table 2 --> price + 3 % I hope it is understandable. My English is not so good. I can also provide an example table. Thank you very much for you help. Greetings from Germany CharlyStellaSolvedCharlyStellaMar 11, 2025Copper Contributor184Views0likes10CommentsHow to add existing log files to a newly created filegroup ?
I have two log files which are on different drives A: \logfile1.ldf & B:\logfile2.ldf which are not part of a file group. I want to remove logfile2.ldf , but I am unable to remove it because it is not empty. I tried emptying it by shrinking , but because it is not part of the filegroup, it failed. When I tried to add the files to a newly created filegroup, using ALTER DATABASE ADD FILE( name= 'logfile1', filename='A:\logfile1.ldf') TO FILEGROUP LOGFILE I got an error message The logical file name "logfile1" is already in use. Choose a different name. So, how can I add the log files to filegroup 'LOGFILE'? Thank you.SolvedwsunarkoMar 07, 2025Copper Contributor82Views0likes3CommentsSearch a string like '%ontario%' in ALL the tables of database
Hi, I want to search '%Ontario%'. How i can search the specific string using like command in ALL the tables of the database from one single query. I want to know which table has like 'Ontario'. ThanksSolvedSmithTorontoMar 04, 2025Copper Contributor74Views0likes4CommentsDifference SQL Server 2022 vs 2017 Bind table
Hi, I'm Beginner SQL Server Engineer. I got some Question to SQL Server 2022, 2017 Bind table. During SQL Server practice, I heard that the bind table does not know statistical information, so there should be no IO reduction due to the index, but in the 2022 version, it seems that the index in the bind table refers to statistical information. something change between 2017 and 2022 Bind table?Solvedezpz97Feb 18, 2025Copper Contributor82Views0likes2Comments
Resources
Tags
- Data Warehouse68 Topics
- Integration Services59 Topics
- sql server54 Topics
- sql44 Topics
- Reporting Services43 Topics
- Business Intelligence36 Topics
- Analysis Services33 Topics
- Business Apps22 Topics
- analytics22 Topics
- ssms15 Topics