Newest 'sql-server' Questions

Q&A for professional and enthusiast programmers

SQL Server SUM then MAX

How can I get the MAX value for the SUM range that I have? Current output: Size | Format | ColB | Value Large | PCT | Tmp1 | 23.05 Large | PCT | Tmp3 | 109.00 Large | PCT | Tmp50 ...

SQL Server mirroring connection issue

Server A : Win 2008, SQL Server 2012, IP : 1.1.1.1 (Principal) Server B : Win 2008, SQL Server 2012, IP : 2.2.2.2 (Mirror) 2 servers are not on the same LAN, no domains, so I need to use IP for ...

MyEclipse Professional on connecting with ms sql server is giving ssl error through db browser

I am using MyEclipse professional and trying to connect with the MS SQL SERVER 2016, i am using the jar file sqljdbc4-4.0 and driver “class name= com.microsoft.sqlserver.jdbc.SQLServerDriver” My ...

How to bulk insert into SQL Server from Excel by query

BULK INSERT dbo.bulkins FROM "C:\BulkDataFile.csv" WITH (FIELDTERMINATOR =',', ROWTERMINATOR = '\n') Error: Msg 4860, Level 16, State 1, Line 2 Cannot bulk load. The file "C:\...

SELECT * FROM online_exam WHERE CONVERT (time, SYSDATETIME()) > start_time AND CONVERT (time, SYSDATETIME()) < end_time [on hold]

result of this SQL query is null... while my table has data that match this time condition someone help me as soon as possible SELECT * FROM online_exam WHERE CONVERT (time, SYSDATETIME()) >...

Remove 'ID' from SQL query

I have a query which adds or removes zeros from ID. SELECT LEFT(STUFF(SystemID + REPLICATE('0', 9), 7, 0, REPLICATE('0', 9 - LEN(SystemID))), 9) as OBJECT FROM Products So ...

PATH as variable in OPENJSON

I want to make a function, which adds value to json-array only if it's not present there. I write a function CREATE FUNCTION dbo.JSON_ARRAY_APPEND (@json nvarchar(max), @arr nvarchar(max), @value ...

Sails Waterline Query Null Value

I am trying to query null values from my database. What is the correct syntax? I am using the sails SQL Server waterline adapter. I have tried: ?ChoiceItem=isNull ?ChoiceItem=Null ?ChoiceItem="null"...

In memory table query performance [migrated]

I am trying to optimize an sql query by using in memory tables. After I had ran the query some times I ran the Transaction Performance Analysis Overview report of SQL Server 2016 which suggested that ...

Using MERGE to insert rows when matched?

I'm using MERGE to insert records in a table but only if a column in the source satisfies a condition. Is the following a valid MERGE statement: MERGE INTO sometable AS [Target] USING ( ...

Converting nvarchar (mm/yyyy) to DateTIme in Sql Server

I have a nvarchar column in Sql Server table which stores date values in mm/yyyy format. Example: 03/2017 Now how to convert this string to datetime so that I can compare this date time with current ...

Error is sending simple form to database using php

Want to create a simple form to send the values and image to database, below is the php code - Created two php file process_upload and connection processs_upload.php <?php require 'connection....

PHP ODBC to MS SQL Server with cursor not recognizing column aliases

When opening ODBC connection with SQL_CUR_USE_ODBC cursor, odbc_fetch_object and odbc_fetch_row will not recognize any column aliases. odbc_result have no such problems. Would be grateful for tips on ...

Subquery with more than 1 value error. Case with multiple columns

I'm, trying to create a query that has 3 columns: 1 column represents the list Job numbers (not nulls values), the 2° and 3rd column represents a sum of values respectively before and after a ...

Bulk Insert return error Msg 7399 and Msg 7330

My problem is when I run the bulk insert it return the following error. Any idea on the error? Some help is appreciated. Actually regarding this issues my testing environment able to execute ...

How to set kerberos weblogic configuration

Where do I need to put this information? grant codeBase "file:/WL_HOME/server/lib/-" { permission javax.security.auth.AuthPermission "createLoginContext.DDTEK-JDBC"; permission javax.security.auth....

SQL Server 2016 - Unable to read Server Queue performance data from the Server service

Hopefully somebody can help me out with the following issue. In December 2016 we started to use a new SQL Server in our company. It's a Windows Server 2016 with SQL Server 2016 installed. The machine ...

Why does this code fail to run in PHP but works fine in Management Studio

I am trying to back up and restore the database from an older backup. I use this SQL code to do this: ALTER DATABASE [UKBYTEDB] SET RECOVERY FULL; BACKUP DATABASE [UKBYTEDB] TO DISK = 'C:/xampp/...

SQL Server error - Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements

I write this stored procedure ALTER PROCEDURE [dbo].[CERRARVIAJE] ( @ViajeID INT, @Reloj MONEY, @Peaje MONEY, @Equipaje MONEY, @Adicional MONEY, @Plus MONEY, @...

unable run restfull webservice in java while connecting to sqlsever

I am trying to call a web service that returns data from my sqlsever database in json format This my code to get data from sqlsever and convert it to a json. Here a function "getAllDataJson()" ...

SQL Unable to remove CHAR(13)

I am looking at a table which has had data items entered into it with a CHAR(13) in it. I can identify the rows easily enough with: SELECT * FROM Preferences WHERE PreferenceName LIKE '%' + ...

Combine two table and create new column in result based second table

I have two temp table, from that want to combine both of them like following.Is there any way to do this? In final result there should consist of new columns based on second tables Tax Type. The ...

Update a term date column based on the next record effective date

Can you please help me on this?I have data in a table as below Input: IDNO EFFECTIVE DATE TERM DATE ------------------------------------- 100 10/01/2001 12/01/2012 ...

SQL CLR function with meta data

I want to write a SQL CLR function that uses data from some tables to perform a function on the given string and return the result. In the interest of performance, is it possible to load the data from ...

Select between dates on DD.MM.YYYY format?

How can I select all rows between two dates, where the dateformat is DD.MM.YYYY? For example between 15.12.2013 and 25.12.2013

how to insert smalldatetime value to data base column

i have one from user table like : Id int Unchecked Name varchar(50) Checked EmailAddress varchar(200) Unchecked Host varchar(250) Unchecked Port int Unchecked POPHost varchar(250) ...

XML column in SQL Server table - combine recurring tag name into one column

I have to query a XML data column in SQL Server and need some help with how I can query some of the individual tags inside the XML. Here is a toy data set that I have been using to test my query: &...

SQL:Show column only if has data in it

Suppose I have a table like this: name | age | experience abc | 18 | 0 def | 19 | 0 efg | 20 | 0 I want to select the experience column only if any one value is greater than zero. In this case,...

SQL Server / Oracle: How to increase index column dependent on another column?

Given the following table: Column1 Column2 idx ------------------- 1 1 0 2 1 0 3 2 0 4 3 0 5 3 0 1 3 0 How could I increase ...

How to script copy and paste for a column with different values every few rows?

I have the table below in Link. Link To table On MS SQL How to copy and paste apples down the column until it hits banana and then copy banana down the column? Same with the years, I want to copy ...

I want to use dynamic variable that is declared within dynamic SQL

declare @sql as nvarchar(500)='' set @sql=' declare @N4 as int = 1 declare @ms as nvarchar(100) = concat(''ms'', convert(nvarchar(10), @N4)) select @ms ' exec @sql I want output ...

Return details of the latest bill linked to the user

I have two different sources of information and I am trying to marry them together to get information relating to a customer and their last bill. I have managed to get details of each customer and ...

Zero-or-one to zero-or-one relationship

Is there a way to create a 0 or 1 to 0 or 1 relationship in a database? For example, let's say I have a table of managers and a table of artists. A manager can only manage one artist, and an artist ...

get data from curor & set into another temp table

DECLARE @MyCursor CURSOR; DECLARE @MyField int; Create Table #DataHold ( CourseChapterLessonID int ) BEGIN SET @MyCursor = CURSOR FOR SELECT CourseChapterLessonID from ...

MSSQL Subquery failing on WHERE clause

Running a 2014 MSSQL Server and MS to interact with it, the following has happened. SELECT T1.Id, T1.DateTime FROM TableX T1 INNER JOIN ( SELECT T2.Id, MIN(T2.DateTime) ...

Same Database URL but different DB name

I am a bit confused by this. Any help is greatly appreciated. QUESTION-1 Suppose, i have my DB Server at location 192.168.1.171:1433. There i have 2 DB named Foo and Bar. So, when i try construct ...

Error reading from Pipe to monitor SQL Server service through WCF

I am using WCF service channnel to monitor SQL Server service running on a remote PC. Running status of SQL Server service is uploading perfectly but when I stop the SQL Server service, then it breaks ...

Copy external Dynamic_partition or static Table from one database to another

I am new for Hive and trying to copy a table from A database to B database which contain 3 partition in a A table Step 1::CREATE TABLE B_ATABASE.S SELECT * FROM DATABASE.table_name; STEP :: TABLE ...

PHP check if a value is equal to any value in another result set?

I have a while loop which is printing out rows from search results, one column in the search result is 'Area Name'. Now I want to check if that area name is also in another result set, and if it is, ...

How to use stored procedure in a sub query to get value in where clause with using main query data as parameters

I want to use a stored procedure GetSLAClass to get a single value for the where clause as seen in below. And also I want to use WRMaster (main table) values as stored procedure parameters. Is there ...

How to Bulk Insert from a select query?

I want to Bulk Insert the result of this query into a table. What should I do? Here is my query : select * from table1 t1 inner join table2 t2 on t1.code = t2.stucode

Ambiguous code in SQL Server

Select DocNo From thecat24 a inner join Thecat23 x on a.N_Solicitud = x.N_Solicitud where x.Codigo_Proyecto = N'2' and DocNo <> 33 It says DocNo is ambiguous and i cant see why? Any fix?

Update rows that have the same values in two columns in MSSQL

My table have the same values in two columns. I would like to update only one row where in column login and email are the same value and data modification is earlier. So, in this example below it must ...

Divide COUNT Column By COUNT(DISTINCT(Column To give avg order size SQL SERVER

Ok I have a list of the months orders so that bit is easy. SELECT COUNT(*) AS ITEMS, For the next part easy to: COUNT(DISTINCT(PICKSET_NO))AS PICKSETS, Its the next part I cant work out: SUM(...

Unable to hide a field on an SSRS report

I've written a report on SSRS which has an initial parameter that you select from. That then shows a specific set of records from a SQL database. However, dependent on that selection I want some of ...

Inserting MAX +1 to New Value in Database

I am pretty stuck on this so your help would be appreciated. I currently have a button that can be pressed that brings up an HTML popup box. The popup box has 2 input fields, SKU Group and Group_ID. I ...

Group by in table

My code is : SELECT Student_ID ,dbo.tblVahed.Vahed_ID, COUNT(Student_ID) AS State_All, CASE WHEN tblStudentsDocument.Student_Sex = N'مرد' THEN COUNT(Student_ID) ...

Should I refrain from using a loop in SQL?

I created a stored procedure that would process data on those table. In order for me to processed those data I have to do a while loop, because I have to compute for the end date which is not ...

Index seek changes to index scan on change of value in where clause

I have a table ORDER having 64 columns, OrderNo being the Primary Key. It has two more columns ParentOrderNo and Type. For lone orders, Type and ParentOrderNo will be NULL and for grouped orders, Type ...

Select rows for a date range applied on one datetime column

In the below table, how to get what statuses the user was in between '2016-12-12 00:00:00.0' and '2017-02-20 23:59:59.999'. The result should be emailVerified and active userid status ...
Translating... 0%