Skip to content

Tag: sql-server

Full SQL statement logging on Dropwizard

I’ve a Dropwizard application using JDBI and SQL Server. I would like to get all SQL statements logged with their parameters but I don’t seem to be able to. This is what’s usually recommended to do: logging: level: INFO loggers: “org.skife”: TRACE “com.microsoft.sqlserver.j…

Perform same SQL query on multiple databases

I’m trying to adapt an SQL query to check the value present in a certain field that is present in every database on my server. There are 100 individual databases, and I would like to check a specific record of each one. The answer is probably to use a command like the one below, but I’m having dif…

Check if a string contains only number

I am trying to check if a string contains only valid number in the following format But it should reject anything that contains non-numbers including double dots. Here are some invalid formats I have done the following When seems to work except for the case where there is more than one dot in the string. How …

Select certain column only if condition met

I want to have a select that will not have fixed number of columns. Column OptionalColumn should be selected only if variable @check = 1 This is what I had (syntax is bad but maybe it explains my problem) It is crucial to have it only if @Check = 1 and not having it if @Check = 0. Is it

Update and insert to one table from another

I have two tables: table1: (ID, Code, Name) table2: (ID, Code, Name) with same columns I want to to insert data from table1 to table2 or update columns if that exists in table2 (table1.ID = table2.ID) What is the simple way to do this? WITH OUT MERGE Answer There are some issues with Merge statement,so it sho…

Convert iso_week to calendar date in SQL

I’ve been searching though the archives without finding what I am looking for- I’d be happy for some guidance. I have a data set where I want to report aggregated number of appointments by provider (STAFFID) and work week, the latter defined by the week’s Monday date. I’ve played with …