Skip to content
Advertisement

Tag: tsql

How to rename database file programmatically?

I have two databases: database_A. Name of file is database_A.mdf. database_B. Name of file is database_B.mdf. Then I what I do: Drop database_A. Rename database_B to database_A: sp_renamedb ‘database_B’,’database_A. However, name of file is still database_B.mdf. Is it possible just by code rename database_B.mdf to database_A.mdf without setting path to location of databases? I cannot use Management Studio to deattach

T-SQL, looking to extract drug dose from column

I have a column of drug names with dose and I’m trying to extract the just the dose from the field. The difficulty comes in when I have combination drugs that have multiple doses. I can either extract the first numbers in the string, or all of them in one string with no way to separate them. Desired output I

Add new key with value = NULL to existing JSON object

I have the following simple JSON object: I’d like to add a new key under application called “approve_date” and would like the value to be NULL. Is there a way to do this with JSON_MODIFY. I tried using ‘append’ in the path but this added an array, not a key (example below). What is the better way to (A) add

group by issue in sql

i’m trying to get in a new column the sessions who are between 08:00 and 18:00. You can see my last CASE in the CTE. For each date there should be a new column “TotalRestrictedSessions” which indicate how many session were on that particular date. If there are none, in this case i have to write 0. I suspect that

Advertisement