I am trying to clone tree structure to another table, but the problem is original table has guid as ParentId and Id and new table or table that I want to clone has int as ParentId and Id. I am trying …
Tag: tsql
SQL for storing numbers from cold to hot for specific range?
We have a table that looks list this: date, val1, val2, val3, val4, val5 for a given row, val1 -val5 are unique and between 1 and 37 Using T-SQL, How can I list numbers 1 -37 by cold to hot with their frequency for a given date range? [![enter image description here][1]][1] Sample Output (NOT ACTUAL): Numbers by frequency descending:
How do you normalize a table with a multi-valued field?
I want to normalize a staging table into two tables. One of the fields of input data contains multiple values delimited by a semicolon. DATETIME | FILENAME | MULTIVALUEDFIELD 7-22-18 | somefile.txt |…
Create an UPDATE statement for every row in a table
I want to update a table on one server with data from a table on another server. The tables have the same columns and I just want to sync the data. I have earlier made a script that creates insert …
Eror While Executing a dynamic queries in a variable
I’m executing a dynamic query from a variable but it always says: Could not find stored procedure I have tried to use simpler queries like set @query = ‘select * from [table_name]’ but it gives the same error. In my temporary table is the list of all my trigger name so the expected output I want to get is Command(s)
Transpose Rows Into Columns by Delimiter Column Name and Column Title
I’m slightly stuck on this issue and need some SQL assistance please. Iv got a hierarchy table from someone who needs help transposing it and putting them into actual columns of another table. Here is …
Query SQL with similar values
I have to make a query to a base using as a comparison a string like this 12345678, but the value to compare is this way12.345.678, if I do the following query it does not return anything. SELECT * …
How can I solve a performance issue in my stored procedure?
I have a performance problem with a stored procedure. Because when I check my benchmark’s result I realized that “MatchxxxReferencesByIds” has ‘240.25’ ms Average LastElapsedTimeInSecond. How can I improve my procedure? Answer Based on the execution plan of the stored procedure, what makes it to perform slowly, is the part where you are going to work with XML. Lets rethink
Getting the personal contact details of an employee
I want to get the Email, Phone and Mobile number of each employee. The ContactDetailsType contains the Label which is email,phone,fax… and ContactDetails contains the ContactDetailsTypeId (the ID of ContactDetailsType) and the Info having the value of the phone number (for example). I tried the following query to get the phone but I’m getting the following error : Subquery returned
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 …