Check if record exists, if yes “update” if not “insert”

I want to check table PREMIUM_SERVICE_USER if any records exists for strClientID update timeValid for +30 if no records for strClientID insert to premium_service_user table. What am I doing wrong? It increases timeValid for +30 days but inserts another row too. SELECT @pre_var = count(*) FROM PREMIUM_SERVICE_USER WHERE strClientID = @strClientID /* bronze premium – […]

SQLServer: How To bind fixed values to Column?

Say I defined a char column Type. I want to strict its value to say for example (Black, White, Red, Blue) Only… How can I do that?? All i know, this is easy in Access 😛

Pass List as XElement to be used as XML Datatype parameter

I have a stored procedure in SQL Server CREATE PROCEDURE ParseXML (@InputXML xml) The data type for input parameter is “xml”. In the LINQ to SQL generated code for the stored procedure the input parameter is System.Xml.Linq.XElement [global::System.Data.Linq.Mapping.FunctionAttribute(Name=”dbo.ParseXML”)] public ISingleResult<ParseXMLResult> ParseXML([global::System.Data.Linq.Mapping.ParameterAttribute(Name=”InputXML”, DbType=”Xml”)] System.Xml.Linq.XElement inputXML) Now, how can I pass the following List to the ParseXML […]

(Additional) EF can't infer return schema from stored procedure selecting from a #temp table

I have a similar problem as described in EF can't infer return schema from Stored Procedure selecting from a #temp table and I have created my stored procedure solution based on the solution described above BUT I am still getting a similar EF error and I really don’t know why or understand how I can […]

Select users belonging only to particular departments

I have the following table with two fields namely a and b as shown below: create table employe ( empID varchar(10), department varchar(10) ); Inserting some records: insert into employe values(‘A101′,’Z’),(‘A101′,’X’),(‘A101′,’Y’),(‘A102′,’Z’),(‘A102′,’X’), (‘A103′,’Z’),(‘A103′,’Y’),(‘A104′,’X’),(‘A104′,’Y’),(‘A105′,’Z’),(‘A106′,’X’); select * from employe; empID department —————— A101 Z A101 X A101 Y A102 Z A102 X A103 Z A103 Y A104 X […]

Get all employee who directly or indirectly reports to an employee, with hierarchy level no

I have a Employee table like emp_id bigint, reports_to bigint, emp_name varchar(20), Constraint [PK_Emp] Primary key (emp_id), Constraint [FK_Emp] Foreign key (reports_to) references [MSS].[dbo].[Emp]([emp_id]) emp_id reports_to emp_name —— —— ————– 1 null Sumanta 2 1 Arpita 3 null Pradip 4 1 Sujon 5 2 Arpan 6 5 Jayanti I want to get all the employees […]

How to resolve Azure “Windows logins are not supported in this version of SQL Server”?

I get the following error message, when I try to connect to SQL Azure. Windows logins are not supported in this version of SQL Server I’m using an Azure connection string. On development I’m running against SQL Server Express. This specific error is thrown when I try to fetch some data from the database. The […]

AngularJS .Net WebAPI Upload image and save to database (MSSQL)

I’m trying to upload an Image(can be bind to a model with a data type byte[]) from UI and save it in the database. I’m using AngularJS connecting it to .NET WebAPI and saving it to MSSSQL Server I cant find a good example using these technologies. Question: What approach is better to use? like […]

Data not Loaded in reportviewer VB.NET

I have created the stored procedure in ms-sql server 2014 and creating the rdlc report. Now binding the report in reportviewer programatically, but in report only columns are displayed and not the data… The below code is my stored procedure : USE [Bonny] GO /****** Object: StoredProcedure [dbo].[AccMast_AllDetail] Script Date: 17/10/2016 12:10:42 ******/ SET ANSI_NULLS […]

SQL Server date format MM/DD/YYYY

How do I check if a date string is in the MM/DD/YYYY format in SQL Server?

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