Tag: sql-server

How To Write Distance LINQ query i have Lat, Long in table with varchar type SQL Server

How to write a LINQ query for nearest points calculation? I have Lat and Lng in a table saved as string in a SQL Server database. Found one solution on stackoverflow the query look like this var coord = DbGeography.FromText(String.Format(“POINT({0} {1})”, latitude.ToString().Replace(“,”, “.”), longitude.ToString().Replace(“,”, “.”))); var nearest = (from h in db.hotels where h.location != […]

SQL Sliding Math

I have a requirement to achieve this in SQL YYYYQ| A | Desired Column ————————– 3Q12 | A1 | A1 4Q12 | A2 | A1 * A2 1Q13 | A3 | A1 * A2 * A3 2Q13 | A4 | A1 * A2 * A3 * A4 I’m using SQL 2012 and tried to use […]

SSRS Column Chart (Bar Chart) needs to appear more clear

I have an SSRS chart with a lot of values on the x axis. I have a requirement that the charts need to be exported to a pdf . My Column/bar chart looks something like this : If I have the chart any wider than this , the chart doesnt look good on the pdf […]

SQL user login access to views only

I have given a user a login to the SQL sever for a selected database with permission on data reader. I would like to know is it possible for me to only give them access to certain view using that login, if so how would i go about doing this

How do put the Time Dimension into order which I imported from an excel spreadsheet to SQL Server?

I imported a Time Dimension from an excel spreadsheet to SQL Server. The time dimension start date is 2005-07-01 to 2025-12-31 (aussie format) Tha attributes is composed of TimeKey Date Date_Name Year Year_Name Half_Year Half_Year_Name Quarter Quarter_Name and all the way to fiscal attributes. Anyways, when I created this TimeDim in the excel spreadsheet, it […]

Entity Framework : Schema specified is not valid

I am developing a web application that is using Entity Freamwork 5 Visual Studio 2012 and it need to support both SQL Server and Oracle database providers. I created entity model for Oracle Database. I thought it would work after some changes in connectionstrings, bu no it is not that easy .. I found this […]

SQL counting the values from two columns and showing the result in other column at the same table

I have two columns in one table, looking like this: CREATE TABLE Invoices ( ID_Invoice… …. UnitPrice decimal (15,2) NOT NULL, Discount (15,2) NOT NULL, ) So I want to add a new column in this table which count the final price – UnitPrice–Discount=TotalCost? Please help.

Encryption SQL Server 2005

I have a SQL Server 2005 Database and I am planning to encrypt some of my columns using PassByPhrase. But these columns have to be displayed in the original form on my ASP.Net web pages and on some Crystal Reports. Now I know that I will have to create a Stored Procedure to decrypt the […]

Cannot get SQL error message

I am tring to run a sql script from my c# application string sql = File.ReadAllText(sqlFile); string[] QueryArray= sql.Split(new string[] { “GO” }, StringSplitOptions.RemoveEmptyEntries); foreach (string query in QueryArray) { cmd = new SqlCommand(query, Connection); cmd.ExecuteNonQuery(); } Then my script contains raiserror statement RAISERROR (‘Cannot procees’ , 20, 1) WITH LOG When I try to […]

Can I execute dynamic sql with sas?

I have a complex dynamic sql query that I execute in t-sql on a sql server. I know you can use SAS to execute simple SQL Select queries. But can you execute dynamic SQL in SAS? Can you execute dynamic SQL remotely?

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