i have BIT data type in sql server and i am trying to migrate it to snowflake but i am not able get the data into snowflake properly 0 goes as 0 but 1 goes into as 255 when i DT_UI1 data type to output the column in sql server can anybody help me how to send bit data type
Tag: sql-server
SQL: Update every entry with value from another entry that share same column value
I have the following table trn_ReceiptLog I am wondering if it’s possible to update amount of entry #1 to have same as entry #2 IF amount of entry #1 is 0? I have over 5000 of these entries that …
SQL Get Parent when child is column is 0
I have two tables below. Data: Using joins I have got the information from both the tables which have needed, but in a new case I need to extract the Address like if the IsNetwork = 0 then Address should of it’s the parent. Following is the query of join This is the output of that query: I want the
How to de-duplicate SQL table rows by multiple columns with hierarchy?
I have a table with multiple records for each patient. My end goal is a table that is 1-to-1 between Patient_id and Value. I would like to de-duplicate (in respect to patient_id) my rows based on “a hierarchical series of aggregate functions” (if someone has a better way to phrase this, I’d …
Remove multiple instances of the same person, different IDs from SQL Server
I have a data set where there are individuals appearning multiple times with the same name and SSN but different personids. I want to remove those people and only keep those that appear one time. In this instance I only want to return Roman Smith and eliminate John Thomas altogether. I’ve been playing a…
FOR XML in SQL Server: Elements based on common values of columns
I’m using FOR XML to create an XML file out of SQL queries. I want to have elements based around common values for a particular column, in this case “location”: I can easily convert his into XML row-by-row like so: Which produces XML that looks liks this: But what I actually want is this: An…
Replace subquery with join for the same table
Can the expected result in this case be accomplished without a subquery ? Maybe using a join ? We have a name say ‘jose’, Expected result is all rows which has same color as jose. Query should run in both MS-SQL and ORACLE. http://sqlfiddle.com/#!18/5f7e3/2 Answer You can get this result with a JO…
Sql Server – Update Statement is locking the table when executed immediately after Rollback Transaction
I have used transaction with try-catch block in my procedure. If any exception occurs, I am rolling back the transaction and after that trying to update a Results (Status) table. But, it looks like the Update statement is locking table (The Select query on that table is not working after that). Could you plea…
Are indexes on columns with always a different value worth it?
Does creating an index on a column that will always have a different value in each record (like a unique column) improves performances on SELECTs? I understand that having an index on a column named ie. status which can have 3 values (such as PENDING, DONE, FAILED) and searching only FAILED in 1kk records wil…
How to determine a percentage gain or loss for a series of people in a table in SQL
I’ve posted a few questions about a system I’m trying to write, and feel bad for asking so many questions. However, I’m still quite new (or revisiting from years ago) to the finer elements of SQL …