Tag: sql-server

Highlight multiple records in a date range

Working with SQL Server 2008. fromdate todate ID name ——————————– 1-Aug-16 7-Aug-16 x jack 3-Aug-16 4-Aug-16 x jack 5-Aug-16 6-Aug-16 x tom 1-Aug-16 2-Aug-16 x john 3-Aug-16 4-Aug-16 x harry 5-Aug-16 6-Aug-16 x mac Is there a way to script this so that I know if there are multiple names tagged to an ID in […]

How to check the state (uncorrupted) of a BAK file with powershell?

I’m transferring a BAK file to ~20 target machines and want to validate that the transfer completed and didn’t corrupt the BAK files when the transfer is complete. This is part of a powershell workflow. I have the following: Invoke-Sqlcmd -Query “RESTORE VERIFYONLY FROM DISK = N’\\TARGETMACHINE\F$\backup.bak'” -queryTimeout -verbose 65534 Which runs and completes in […]

Execute stored procedure in ASP.NET MVC and LINQ

I’m very new to ASP.NET, so this may be a very basic question. Anyway, I want to execute a stored procedure on a server. I’m using, as in the heading mentioned, ASP.NET MVC. Currently it is possible to query the whole table: Controller: public JsonResult GetLaptopsJson() { Laptop[] laptops = context.GetTable<Laptop>().ToArray(); return Json(laptops, JsonRequestBehavior.AllowGet); } […]

Import images from folder into SQL Server table

I’ve being searching for this on google but I haven’t found any good explanation, so here’s my issue. I need to import product images, which are in a folder to SQL Server, I tried to use xp_cmdshell but without success. My images are in C:\users\user.name\Images and the images have their names as the product id, […]

Entity Framework translates all columns when using group by

When using the below LINQ to Sql expression, it gets translated into SQL with all columns instead of only three (LocationId order, ArticleID orderItem, Qty orderItem). var query = from orderItem in ctx.OrderItem join order in ctx.Order on orderItem.OrderID equals order.ID where order.Received == false group orderItem by new { order.LocationID, orderItem.ArticleID } into g […]

Powershell select value from datatable where

I have a data table that I have imported from SQL which has two columns. One is country code and the other is country name. I have a CVS import of country names and I want to go through the data table with each country name and get its corresponding country code. If it were […]

Unhandled exception while installing setup of windows application

I have created windows application in Visual Studio 2015 and my database is in SQL Server 2008 R2. I published it through properties window of solution. It works fine on my laptop. But when I going to install it on other laptop, it shows unhandled exception ‘Underlying provider failed on open’. I installed .NET Framework […]

SQL Sever – max # of 8k pages in a file?

MSDN says here: msdn maximums that max datafile size is “16 Terabytes” – not sure if their definition of terabyte is 1024^4 or 1000^4 – so valid max page number might be 2,147,483,648 (for 1024 basis) or 1,953,125,000 (for 1000 basis) or perhaps something else – does anyone know with certainty? I have heard that […]

SSIS Package not updating modified date on Excel

I have a SSIS Package that looks at a template designed in Excel ( 95 – 2003 worksheet) Copies that template to a new location. (File System Task) Populates that copied Template using OLE DB Source to Excel Destination. [ [ All works great. Except the customer has noticed that when the new excel is […]

Keeping the results with GROUP BY

I connect four tables, but if I do a GROUP BY with a propertie of the fourth table, I get different results. This is the Query:

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