How can I group by date time column without taking time into consideration
Cast/Convert the values to a Date type for your group by.
Cast/Convert the values to a Date type for your group by.
I know this is an old question. The way I solved it – after failing by increasing the length or even changing to data type text – was creating an XLSX file and importing. It accurately detected the data type instead of setting all columns as varchar(50). Turns out nvarchar(255) for that column would have … Read more
Someone connected to the database. Try to switch to another database and then, to drop it: Try SP_WHO to see who connected and KILL if needed
It’s pretty much the same as running a query. In your original code you are creating a command object, putting it in the cmd variable, and never use it. Here, however, you will use that instead of da.InsertCommand. Also, use a using for all disposable objects, so that you are sure that they are disposed … Read more
Assume a table structure of MyTable(KEY, datafield1, datafield2…). Often I want to either update an existing record, or insert a new record if it doesn’t exist. Essentially: What’s the best performing way to write this?
Check to see if your user is mapped to the DB you are trying to log into.
There are issues with leap year/days and the following method, see the update below: try this: OUTPUT: UPDATE here are some more accurate methods: BEST METHOD FOR YEARS IN INT you can change the above 10000 to 10000.0 and get decimals, but it will not be as accurate as the method below. BEST METHOD FOR … Read more
You need to download and install SQL LocalDB. It is a special edition of SQL Server that does not allow remote connection and supports windows integrated authentication only. It is a simple one click MSI install so it is easy to deploy. To download and install SQL Server 2016 Express, go to SQL Server downloads. LocalDB is a … Read more
I have MS Sql server 2012, and Office 2013. This seems to be very finicky, so you may have to adjust to your particular versions. Download the Microsoft.ACE.OLEDB.12.0 for Windows, 64 bit version found here: https://www.microsoft.com/en-us/download/details.aspx?id=13255 Install it on your server. Check the user running SQL Server and make sure that user has access to the … Read more