I have total of 3 tables in my database. My Testing1 and Testing2 table have two exact columns (ItemID and ItemPath). My Testing3 have three columns (ItemID, ItemPath and Source). I’m trying to compare Testing1 with Testing2 and insert the difference to Testing3. I’m able get the the difference but I’m just wondering how can modify it to meet this
Tag: sql-server-2012
SQL Group Multiple Results from Single Table
I have a table that contains a line entry for each item that I need to group into an output with all the values of multiple rows that have the same uniqueID into one column result. The ItemType will be different but the UniqueID and OtherData shouldn’t change as it’s tied directly to the UniqueID, but I’m not 100% sure
Need to get the value from a column whose column name is based on a value in another table
Table A has columns ID, COL1, COL2, COL3. Table B has columns AID, ColumnName. I need to get the [ColumnName] value in Table A based on the value of [ColumnName] in Table B. In the example below: For ID 1, I need to get the value of column COL1 (This is the value of [ColumnName] for AID 1 in Table
split one column values into multiple column based another column value
could you please help me writing select query to get expected output from the below picture. what I want is to split the UPC column values into three columns(Bottle UPC, Pack UPC, Case UPC) based on its UOM column values ZF2, ZF1 and ZF3 respectively. any help would be appreciated. Thank you! Answer This is one way to get the
Trigger causing Maximum trigger nesting level exceeded
I have created a new trigger that updates my [Purchase Table] if the number of delivered items equals the ordered quantity, but every time it’s run I get the following error. ODBC–update on a linked table ‘dbo_Purchase Table’ failed. Maximum stored procedure, function, trigger or view nesting level exceeded (limit 32). (#217) This is the trigger that I have created:
Return Date Ranges based based on a given interval between two given dates in SQL
I am trying to get a list of all DateRanges of a given interval between two dates. For example if I have the dates 2015-04-01 and 2015-06-20 and when the interval is 20 the result should be Here is the query I am trying Its returning the below result which is not exactly as my expected result above Here as
Looping through a column to check if a cast succeeds in SQL Server
I am trying to check if an entire column which is varchar and make sure it can be cast to float. I have a cursor portion like so: For some reason, it is always returning 1. I already in a previous part of the cursor (not shown but above), verified that the column passed in (@ColumnName) is NOT NULL at
retrieve different format of date values with time from string (t-sql)
I have a requirement where i have to pull the date/time value from string but the problem is that they can be different formats because of which substring becomes more complicated. Here’s what i came up with but is there any other method where i could simply retreive dates of different format with time and convert them all in single
Insert data into a table from Open Query with variable
I am trying to using OPENQUERY to pull some data into a table. Here’s what my code looks like: I end up with the following error: An INSERT statement cannot contain a SELECT statement that assigns values to a variable. When I attempt to run the EXEC(@TSQL) without the INSERT it works like a charm, but I am unable to
Include Medians for grouped query .
I have this query that I need to graph. The graph will show Total patients, patient Longest wait (minutes) and patient Median wait for each location. I need to include Medians in my query, and that is where I am stuck. Example Raw Data: Query I have so far w/o Medians: Output: I need help getting a last column of