How can I generically detect if a database is 'empty' from Java

Can anyone suggest a good way of detecting if a database is empty from Java (needs to support at least Microsoft SQL Server, Derby and Oracle)? By empty I mean in the state it would be if the database were freshly created with a new create database statement, though the check need not be 100% […]

MSSQL: Get Subtotal of a total

How can I write a query to get the subtotal of a total? Example is below. select task_id, client_id, SUM(value1 + value2) AS ‘Total 1’, SUM(value3 + value4) AS ‘Total 2’, –pseudocode SUM(Total 1 + Total 2) AS ‘Total 1 + Total 2’ from table1 GROUP BY task_id,client_id Expected Results: task_id | client_id | Total […]

Return specific data from SQL query and error invalid column name

The SQL query below is returning the data I require, however on the table column “Payment status”, “awaiting payment” and “paid” is returned for organisations, I want Payment Status (Paid/Unpaid) returned for companies and not the above. I was thinking that this might be a where clause WHERE payment status only equals “Paid” AND “Unpaid”, […]

Change the Connecting string of the C# windows form application to it in another computer

I have a C# windows form application and I connect it to the SQL server in my computer. Now I going to deliver the software to a user. So, what can I do to change the connection string to the user SQL server? Is there any way to do the connection string computer independent? Kindly […]

SQL Server: Making Monday the start of week

I have an issue (and as reading, it’s not just me) with SQL server settings for Sunday as first day of week. But my company needs the weeks to cover the period Monday-Sunday. I tried SET DATEFIRST 1, but it doesn’t affect the results. A simple example: today is Sunday; when I enter the following […]

Storing dates in a single column in sql by transpose?

I’m trying to generate a single column that has a list of dates for the ends of various months plus today’s date. So far I have: DECLARE @date DATETIME = ‘7/1/2016’; SELECT CONVERT(char(10), GetDate(),126) ,EOMONTH ( @date, 1 ) ,EOMONTH (@date, 2) ,EOMONTH (@date, 3) ,EOMONTH (@date, 4) ,EOMONTH (@date, 5) ,EOMONTH (@date, 6) ,EOMONTH […]

SQL Server: Select rows where value in column changes from list of values to another list of values

Let’s say I have this table in sql server database, sorted by increasing hist_pp: hist_id hist_yr hist_pp hist_empl_id hist_empl_sect_id 90619 2017 5 00018509 61 92295 2017 6 00018509 61 93991 2017 7 00018509 61 95659 2017 8 00018509 99 103993 2017 9 00018509 99 120779 2017 10 00018509 99 I want to find the rows […]

Load CSV by matching table column to SQL using PowerShell

My requirement is to load system generated CSV file into an SQL table. Below I’m providing the CSV file, table query and my code. Below are the CSV files abc.csv and xyz.csv which column comes changing by column every time like in the second file as you can see last two column shuffled. id,Name,name,Shift,Day,Night 1,ert,sdf,08/21/2017 […]

Search after current day in MS SQL

i have a table, look like this: I want to select just the rows with current date. SELECT Mandant, BelId, Typ, Datum FROM myTable WHERE Datum = DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0) this is not working i’m getting an empty table SELECT Mandant, BelId, Typ, Datum FROM myTable WHERE Datum = CONVERT(date,GETDATE()) this is also […]

how to find particular word from one table which is present in table 2

table_name1 : citymaster id cityname 1 Florida 2 Newyork 3 Hydrabad table_name2 : Details id detail 1 I am from washington 2 Newyork is beautiful 3 It is said that, Florida is very beautiful table_name3 : Cityfromdetails (Which is the output table) id City 1 not available 2 newyork 3 Florida I want third table […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.