The binary representation of integer 170 is 1 0 1 0 1 0 1 0
Reversing the bits gives 0 1 0 1 0 1 0 1
That converted to decimal is integer 85.
Why does SELECT ~170
I am struggling to understand what I am missing here.
I would like to select data from 2 tables into one json string. First table should list all linked tables from second table like
SELECT [orderNumber], [tcpState]
SELECT [startdate], [enddate], [tcpStat... more
I have to do this in SQL Server. Assume that I have 2 tables.
Based on parameters Name and Surname, I have to take PhysicianID from Table1.
After that I have to create new record using insert into stored procedure.
Something like this
CREATE PROC... more
I have a dataset with 50,000 records. The format is like shown below.
Handle | Category | A | B | C | Misc Info
H1 | X | 100 | 120 | 150 | kk
H2 | Y | 100 | 120 | 150 | mm
As per my below query, How i can get the last row with value "0" if there is no data in "inc" table between the selected dates.
Calls = count(*)
, Cust = i.Cust_id
, Contract = c.con_id
, Serv_Time = sum(Serv_Time)
postId Tag Author
1 A,B x,y
2 B,C,D x
3 C,D y
How to select records that have Tag='B' in the comma separated string? From the above example it should return record 1,2.
I am trying to solve a backup problem for SQL Server 2012 for some time now.
The problem is I not able to make backup TO DISK, I think it is directory error
BACKUP DATABASE [ProjectDatabase]
TO DISK = 'C:\Users\AizazHussain\Dropbox\T... more
I have some sample data like:
INSERT INTO mytable
(11, 1), (11, 2),
(12, 1), (12, 2), (12, 3),
(14, 1), (14, 2), (14, 3), (14, 4),
(15, 1), (15, 2), (15, 4)
Now, here I am trying to ... more
I have some sample data like:
INSERT INTO mytable ([ID], [FK_ID], [TYPE_ID])
(1, 10, 1),
(2, 11, 1), (3, 11, 2),
(4, 12, 1), (5, 12, 2), (6, 12, 3),
(7, 14, 2), (8, 14, 3)
Now, here I am trying to check if in each group ... more
I have a C# SQLCLR Stored Procedure in which first data is filled in some dictionaries and is computed and then the output is stored in some other dictionaries.
This computation is done very fast because of the usage of Dictionaries and completely j... more
I wrote a function using dbListTables from the DBI package, that throws a warning that I cannot understand. When I run the same code outside of a function, I don't get the warning message.
For info, the database used is Microsoft SQL Server.
I am having three tables viz., Employees, Department and Grievance. The Employees table has over a million records. I need to find the details of the employee, his/her department and grievances raised by him/her.
I could think of the below two queri... more
Well, I am building a small hobby program in C#, and I am trying to write information from my program to Sql
The thing is I have some varchar fields in Sql with a max length of 50
when I send information to fill those columns they will be added with... more
I have a textbox where you input a number, this works.
I have a datagrid that pulls data from an MSSQL database utilizing a stored procedure based on the number from the textbox, this works.
NOW I want to click on a row and it writes a specific val... more
In SQL Server 2014, the master database contains a system stored procedure called sp_rename. I was interested to know how it works, so I've been taking a look at it.
On line 190, there is an EXEC statement that contains two percent signs:
EXEC %%Sc... more
i am part of database development team wotking for big eshop. We are using MS SQL 2016 and ASP.NET. SQL Server is used by clients from 10+ IIS servers using connection pooling (we have aprox 7-10k batch/sec) in production environment and we are using... more
I am trying to compare names in 2 different tables.
In Table1 the field is called Name1 and has values like Lynn Smith.
In Table2, the field is called Name2 and it has the value like Lynn Smith (Extra)
How can I compare the two name values ignorin... more
What SQL query do I need to use to get an alternative parts list based on a common reference number. The common reference in the Example below is ELS though the real table is over 100,000 rows with variable references.
**Reference Part... more
I have a simple query like below:
[dbo].[Tenants] AS [Extent1]
LEFT OUTER JOIN
[dbo].[Sectors] AS [Extent2] ON [Extent1].[SectorId] = [Extent2].[Id]
(CONTAINS([Extent1].[Name], '"asdf*"')) OR
I am trying to calculate churn of customers based on activity they could have done, opposed to churn by date that is the normal thing. We have events that is connected to a specific host, in my example all events are hosted by Alice but it could be d... more
I have the following table:
create table dbo.Link
FromNodeId int not null,
ToNodeId int not null,
Rows in this table represent links between nodes.
I want to prevent inserts or updates to this table from creating a cyclic relationship... more
I want to split a string at each character and display each of them in a separate row. I also need an extra column (Col2) which should display whether the character is a number or not (if number, then 1 else 0).
If the data is 'October 11,... more
Given few strings as
SET @Codes1 = 3,4
SET @Codes2 = 1
SET @Codes3 = --empty
Table -- TblCode
How to convert the @Codes1, @Codes2, @Codes3 with join to the table TblCode so it returns the following out... more
I'm working with a legacy DB that has a table that houses field names from other tables.
So I have this structure:
Field_ID | Field_Name
1 | Col1
2 | Col2
3 | Col3
4 | Col4
and I need to pull a list of this field met... more
I have a bit column in my table. I want to add a new column of int (an enum). No problem. However I want to migrate the data in the bit column to map to the new integer column.
Specifically, I would like any rows in the bit column that were true (1)... more
I am using sqlplus and I want to extract all contact numbers which contains any character apart from [0-9, '-','+', '(',')',' '] in SQL? I tried this
select VOICE from MERCHANT_MP_CONTACTS where (VOICE not like '%[0-9]%')
select VOICE from MERCHANT... more
Suppose to have this query:
SELECT ((ColumnA*ColumnB)/ColumnC) AS ColDerA
,(ColumnD + ColumnE - ColumnF) AS ColDerB
,(ColDerA - ColDerB) AS ColDerC
When I write (ColDerA - ColDerB) AS ColDerC SQL return this error:
This is a problem as old as the hills, and nearly everyone would have encountered it. So, I'm looking for the most common, and most solid solution.
If I have a primary key column in a table, other tables have foreign keys linked to that column, and ... more
I am working on a query to show patients who are on certain types of medication. I have a list of a few different meds that I'm seeking -- I am looking to see if there are any patients in the database who have a prescription for any of these medicati... more
I have the following:
And I've got this query:
SELECT COUNT(a.dateOfInquiry) as NumberRecords
SELECT ROW_NUMBER() OVER(ORDER BY dateOfInquiry ASC)
We have a table that contains resources and the days' that they work. For example, one person could work Monday - Friday but another could only work two days of that week.
Here is the data:
WorkOnSunday WorkOnMonday WorkOnTuesday WorkOnWedne... more
Hi I have a table with lots of clients that can have 2 appoint types. What I'm trying to do is select both types of appointments, however, only if apptType=1 has a date apptDate between 01/01/2016 and 06/30/2016.
ID Clien... more