T-SQL select if person has product A but not both A and B

I’m unsure how to achieve this. I would like to get persons that have “ProductA” but not those who have both “ProductA” and “ProductB”. Expected output: CustomerID | Product ——————– 1 | ProductA 2 | ProductA 3 | ProductA 6 | ProductA 7 | ProductA Table: CREATE TABLE #TempTable ( CustomerID INT, Product VARCHAR(50) ) […]

Sql server with Bonobo GIT

I have configured Bonobo GIT and it’s working fine with SQL Lite. Can we user SQL Server with Bonobo GIT? If, Yes then where can I find the ready made database?

What does a query return in SQL Server?

When we execute an “Alter” query in SQL Server, we get “command executed successfully” message. So my question is, what makes SQL Server show that message after execution of the query? As far as in know, that query may return some value, depending on that value, SQL Server decides which message to show. So, what […]

How to write into a table without locking other transactions

I have a central logging table, where various activities are logged. There is a procedure used for writing into the log, like this: create procedure [client].[procClient_LogText] ( @LogText nvarchar(4000), @LogLevel tinyint = 1, @LogLongText nvarchar(max) = NULL, @LogModule nvarchar(200) = NULL ) as insert into dbo.tblLog(LogLevel, LogText, LogLongText, LogModule) values (@LogLevel, @LogText, @LogLongText, @LogModule); Now […]

The name datetime is not permitted SQL Server

I am trying to insert the following query into my table insert into leave values (‘0101’, ‘ibrahim shaikh’, (datetime, ’26-11-2016′, 105), (datetime, ’26-11-2016′, 105), ‘1’, ‘nov’, ‘0’, ‘test’, ‘2016’, ‘0’, ’11’, ‘1’) but I am getting the error Msg 128, Level 15, State 1, Line 1 The name “datetime” is not permitted in this context. […]

Query to find records following same sequence of patterns?

How to find records which matches certain sequences from the below table: ID s_id task 1 1 a 1 2 b 1 3 b 1 4 c 1 5 c 1 6 d 1 7 a 2 1 a 2 2 c 2 3 c 3 1 a 3 2 b 3 3 c 3 […]

How can prevention of Divide by zero error encountered in sql server?

I’m new in sql server and write this query: SELECT y.Telno, t.Cycle+’-‘+y.Cycle Cycle, (((y.CurBill – t.CurBill)/t.CurBill)*100) Price FROM [ClubEatc].[dbo].[GetOnlineBills] y INNER JOIN [ClubEatc].[dbo].[GetOnlineBills] t ON y.Telno = t.TelNo AND CAST(y.Cycle as int)-1 = CAST(t.Cycle as int) in table [GetOnlineBills] in field CurBill some place save zero,and the i get zero divid error,want when CurBill equals […]

Check if a sequence of records contain a specific value

I am trying to find records not having a specific value in a sequence: Customers Table: For instance, I need to find all customers not having “Value F” on record. SELECT * FROM Customer WHERE VALUE NOT IN ‘Value F’ would also return values A, B, C, etc.

Temp Table creation is throwing error in same session even dropping and recreating also

I have below code. In this i am dropping and re-creating a same temp table in same session. But table is not getting dropped while creating it second time. It’s throwing an error.Can any one help me with reason? Thanks in advance. IF OBJECT_ID(‘TEMPDB..#Table1′,’U’) IS NOT NULL BEGIN DROP TABLE #Table1 END CREATE TABLE #Table1 […]

SQL web Reporting from multiple databases

Firstly let me start by letting you know that I am new to SQL reports. What I have is 2 independent customers, each have the same database structure, just on different SQL database machines. What I want to do is create a reporting suite and have the customers use this so that they can run […]

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