Given a SQL query: How do you determine what index to write to improve the performance of the query? (Assuming every value to the right of the equal is calculated at runtime) Is there a built in command SQL command to suggest the proper index? To me, it gets confusing when there’s multiple JOINS that us…
Tag: sql-server
Msg 100, Level 16, State 0, Line 109 insert statement error
While inserting the values in this table error occurred.and after adding constraints it’s not working on that condition too. What to do?? Answer When you have defined relationship then data should be present in Parent table first before inserting the data in child table otherwise data in child table is …
Is there a way to separate query results in SQL Server Management Studio (SSMS)?
I got a simple query which return a results from an OrderLine table. Is there a way to visually separate the query results to make it easier to read, like in the image shown here? Results: Answer
Migrate columns to JSON in SQL
I have a table (Table A) that looks like this: I want to convert it to a table (Table B) like this How do you insert/transform into a json column? Or do I just have to construct the json string myself? Additionally, does the nullableness of the int columns affect creation? Are clicks for example not included …
Select from dynamic table
I need to run a query in sql that depending on the month and year I need to call a different table. For example: If current_date is 31/08/2020, execute: select * from table_ago If current_date is 01/09/2020, execute: select * from table_sep Is it posible using a query in SQL Server? Answer You can use a store…
I need some help in a query in SQL Server [closed]
I need a query that filters from the first day of the previous month and the current day at 0 hours. Can anyone help me?
Enabling CDC in SQL Server 2005 won’t work?
I am trying to use AWS replicate following this tutorial – https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Source.SQLServer.html#CHAP_Source.SQLServer.CDC.Publication . Using this code on a 2005 Microsoft SQL table Results in Could not find stored procedure ‘msdb.dbo.rds_cdc_enable_db’…
Partition Over Clause with start and stop
I have a set of data where value is calculated starting from 1 – 12 then moves 1 step down and calculates another 1 – 12. This works well in Excel however how do I achieve this in SQL. Is it even possible? I have tried which gives me a list of numbers then restarts after 12 so I want
Get users attendance entry and exit in one row SQL Server
I have a table with all entries for employees. I need to get all the working hours and the entry and exit time of the user in one record. The table is like this: How can I do that and also in case there is some missing entries or exit. Like one employee will have entry with no exit in
convert access group by query to sql server query
I’m unable to convert MS Access query to SQL SERVER Query, with changing the group by columns because it will effect in the final result. The purpose of this query is to calculate the Creditor and …