Questions tagged as 'sql-server'

1
answer

Extract xml tag from a varchar (max)

Hello, I have a series of xml records in a varchar (max) column and I need to extract the <MT_USADA>16 MB</MT_USADA> tag, for example: <?xml version="1.0" encoding="utf-8"?> <consulta xmlns:xsd="http://www.w3.org...
asked by 26.06.2018 / 22:04
2
answers

How to return a specific column as an element with FOR XML AUTO clause

I need to make a particular column an element in the return XML when I use the FOR XML AUTO clause. Automatic return turns all fields into attributes of the corresponding element. All right, but one field or another I need to be an element. I...
asked by 02.03.2018 / 20:39
1
answer

How to use the merge statement in sql server

I would like to know how to use the MERGE statement. When should I use and what are the advantages and disadvantages of using it?     
asked by 18.01.2018 / 12:47
3
answers

drop table with temporary table giving error

qryCIDtemp.SQL.Text := 'drop table if exists #tempCID'; //apaga a tabelas temporária Delphi returns the following message at runtime: Invalid use of keyword Token: if Line Number: 1. If anyone can help me, I'm very grateful. EDIT: T...
asked by 20.06.2018 / 18:15
1
answer

SQL Server - split function

I have the following table: The purpose is to do a function of the EixoX column in SQL Server where TipoGrafico is different from 'StockChart' >. That is, if TipoGrafico is different from 'StockChart' then I...
asked by 27.07.2018 / 11:52
1
answer

Equivalence between EXCEPT | INTERSECT & exists | not exists

Would it be EXCEPT | INTERSECT always equivalent to not exists | exists ? Having the following query SELECT ProductID FROM Production.Product INTERSECT SELECT ProductID FROM Production.WorkOrder I could write as fo...
asked by 01.12.2017 / 16:45
1
answer

Use Datepart as Query Parameter

I'm developing a system and am bumping into a SQL query that consists of the user searching by Date and will have the option to choose whether the query will be done by adding Weekend to those dates, excluding the weekend or just consulting the...
asked by 22.11.2017 / 03:27
2
answers

Structure of tables in user question and answer template

I have a question in the structure of some tables and I hope you can clarify in detail below. Scenario The system will generate a way to create dynamic forms and questions in order to be answered by users already registered. Respons...
asked by 19.02.2018 / 01:03
2
answers

Cursor problem: SQL Server

I have a problem with the cursor part: cursor with the name 'BankBank' does not exist. sql code: if @Opcao='1' begin set @tipoPagamento='20' set @LayOut='040' declare C...
asked by 18.05.2018 / 13:33
1
answer

decimal places of a variable numeric field depending on the CASE in SQL

I have a query where, depending on a parameter, I need the result in a field to be 5 decimal places or 2 decimal places, is it possible in SQLSERVER 2008? Example DECLARE @VALOR DECIMAL(18,2), @PORCENTOJUROS DECIMAL(18,2), @CODJUROS INT S...
asked by 21.09.2017 / 22:33