Tag: sql-server

sql server update table

the table: CREATE TABLE [dbo].[User] ( [UserName] NVARCHAR (100) NOT NULL, [Pasword] NVARCHAR (100) NOT NULL, [Name] TEXT NOT NULL, [LastName] TEXT NOT NULL, [Location] TEXT NOT NULL, [profesion] TEXT NOT NULL, [Email] NVARCHAR (50) NOT NULL, [Gender] TEXT NOT NULL, PRIMARY KEY CLUSTERED ([UserName] ASC) ); i want to update to: CREATE TABLE [dbo].[User] […]

SQL Connection String Security

We have a internal asp.net website running on IIS with Windows Security. From what I understand (and observe) this means that each thread runs using the credentials of the user who connects to the website. The website connects to a SQL Server 2014 database. We use a SQL Server username and password to make the […]

Hide characters in email address using an SQL query

I have a very specific business requirement to hide certain characters within an email address when returned from SQL and I have hit the limit of my ability with SQL to achieve this. I was wondering if someone out there would be able to point me in the right direction. Essentially, my business is asking […]

Azure SQL is extremly slow while operating on multiple rows

In my Azure SQL database (S0 10 DTUs) I have Products table with 80k rows. From Management Studio I’m running the following query: UPDATE Product set IsActive = ‘true’ It runs for almost 3 minutes utilizing nearly 100% of the DB resources. The same query executes in less than 10 seconds on my local machine […]

IQueryable Union, Unable to create a null constant value of type 'System.Collections.Generic.IEnumerable`1[[System.Int32

I am trying to implement LINQ query to Entity Framework with union. Let’s say I have 2 tables: Users and TempUsers. I try to: var users = context.Users .Select(u => new UserModel { Name = u.Name, Roles = u.Roles.Select(r => r.Id) }) .Union(context.TempUsers .Select(u => new UserModel { Name = u.Name, Roles = null })) […]

Determine ODBC database driver from TADOConnection object?

Using Delphi 7 with ADO objects, is it possible to determine the ODBC database driver from the TADOConnection object? So detect whether it is MS-Access or SQL Server or Oracle etc. The program connects to a database by just using the name of an ODBC data source, and I want to determine whether that database […]

Select SQL statement group by and sum two columns

I have an sql statement which I cant get the structure right on, when I run what I currently have It says syntax wrong. I am looking the result to look like this:- Valid XHTML http://www.churchcom.co.uk/test/Capture2.JPG. This is my query so far but I dont think I am on the right track at all. SELECT […]

return two character from function containing numbers and alphabet in SQL

I want to make function which will return two character based on the condition. let say I have a table tbl_Dummy CREATE TABLE [dbo].[tbl_Dummy]( [Id] [varchar](2) NOT NULL, [Name] [varchar](30) NOT NULL ) if Max value of Id in tbl_dummy is 01, then it returns 02, and so on, when it passes to 09, then […]

Dynamic SQL to use columns as parameter. ISNULL() function isn't working anymore

I am trying to use a stored procedure, which contains parameters, which should be used as column names. So for example something like this Select * from table1 where @columnparameter = ‘test’ One approach I’ve found to realize it, was to use a dynamic sql and so far it is working. But I also want […]

SQL Error on index view after database creation with EF and MVC (Cascading delete issue)

I’ve seen some similar problems but I am not sure what is causing the cascading delete issue. These are my classes: public class Game { [Key] public int GameID { get; set; } public int GenreID { get; set; } public int ConsoleID { get; set; } public int CompanyID { get; set; } public […]

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