Yes i know, there is alot of material out there on how to turn on identity insert and turn it off after, which is actually something i want to use. But there is more to my problem, thats why i started …
Dynamically Updating Columns with new Data
I am handling an SQL table with over 10K+ Values, essentially it controls updating the status of a production station over the day. Currently the SQL server will report a new message at the current …
How can I safely create a query that will list column names given a table name, and a connection string which may point to SQL Server or MySQL?
I have the following method at the moment which works for my particular two databases, but I’m not sure if it’s the correct way to achieve my goal of listing column names, or is a bit hacky. One part …
How to extract data from this table and convert it into this specific format using t-sql?
I am using SQL Server 2014. Below is the extract from a table called Table1: ID Market Adult AdultAge 0-5 6-12 13-17 100 UK 1 50 0 0 0 105 UK …
Hide data for all but first row on left join column
Let’s say I have this query for a view: select a.name as Author,b.name as Book from a left join b on a.id = b.a_id and it produces this output: Brandon Sanderson Mistborn Brandon Sanderson Way of …
Create a stored procedure which includes return records
I am trying to create a stored procedure which has 3 parameters. Another software will call my procedure with parameters in order to query a bunch of records. The stored procedure includes only a …
INSERT ‘X’ If another column is updated
I need to update column firstname in table Taulu ( removing single quotes ). I also need to add ‘X’ to another column sq if values where updated. I would like to update this in one statement. What I …
Adding SQL Rows from two CTEs
I have two CTEs that I’ve unioned two produce the following result: date serie events 2019-05-09 hello 175 2019-05-02 hello 196 2019-05-09 goodbye 1 2019-05-02 goodbye 1 I want to add …
why “CURRENT_TIMESTAMP” showing wrong time in SQL?
I am using “CURRENT_TIMESTAMP” for automatic date setup inside the column for each row in SQL. It shows date and time but time is wrong. please help.
Unable to identify syntax issue with using MAX and OVER PARTITION BY
I’m trying to answer a SQL Leetcode question on Medium Difficulty. The question is asking me to find the people that have the highest salary per department. I tried using GROUP BY but wasn’t able to …