Questions tagged as 'sql-server-2008-r2'

1
answer

How to convert a boolean to string in a Store procedure SQL

I have the following procedure (select) that gives me some information: SELECT id_accion, accion_tomada, CAST(fec_inicio AS VARCHAR) AS fecha_ini, CAST(fec_fin AS VARCHAR) AS fecha_fin, estatus FROM detalles WHERE id_downtime = @id_dt...
asked by 02.05.2018 / 22:44
7
answers

Get only month and day using SELECT in SQL server

Use SQL server 2008 R2 I want to make a simple select that using a GETDATE() show a specific date format without year:    day / month This select gives me the values but in separate columns SELECT MONTH(GETDATE()...
asked by 26.10.2016 / 16:23
2
answers

Convert 'dd / MM / yyyy hh: mm: ss' to 'hh: mm: ss tt', SQL Server

Assuming I have the following Date / Time in a tabla of the Database:    Entry : 05/03/2018 08:00:00.000   , Exit : 05/03/2018 18:00:00.000 I need to get the following output: Entrada : 08:00:00 a.m....
asked by 05.03.2018 / 20:08
2
answers

Error: An INSERT EXEC statement can not be nested. SQL Server 2008 R2

I have an sp which I want to store inside a temporary table, either a table variable or a temporary table, in both cases, this error marks me:    An INSERT EXEC statement can not be nested. This is my code that I am generating to store th...
asked by 05.06.2017 / 17:38
2
answers

Difference of exact hours between Date A and Date B

$qry = "select CONVERT(VARCHAR(20),fechaSalida,108) AS fechaSalida, CONVERT(VARCHAR(20),fechaEntrada,108) AS fechaEntrada, CAST(DATEDIFF(minute, fechaEntrada, fechaSalida)/60.0 as decimal (18,2)...
asked by 18.09.2018 / 22:34
1
answer

Duplicate automated log SQL server

I have the following problem: In the BDD I have records of thousands of products with the invoice date and the amount that was sold. What I need is to add records for all the product codes that I have registered, taking all the dates from the...
asked by 27.08.2018 / 21:19
2
answers

Create a table if the database exists, if not create it in another database

I want to verify if there is a database BDDATOS1, if it exists I create a table in this database BDDATOS1, otherwise I create a table in database BDDATOS2. When I run the following IF EXISTS(SELECT * FROM master.dbo.SYSDATABASES WHERE NA...
asked by 26.08.2017 / 18:30
2
answers

Declare scalar variable in Stored Procedure

I have the following SP and it marks me the following error in the SP:    SQLState = 37000, NativeError = 137 Error = [Microsoft] [SQL Server]   Native Client 10.0] [SQL Server] Must declare the scalar variable   "@Today". SQLState = 37000, N...
asked by 15.01.2018 / 17:39
1
answer

Error executing the DBCC SHRINKFILE command in the Log File of a SQL Server database

The following sql code for the compaction of the log: use My_dabase go declare @arch_log sysname set @arch_log =(select name FROM SYSFILES where fileid = '2') select name from sysfiles ALTER DATABASE My_database SET RECOVE...
asked by 17.01.2018 / 23:26
2
answers

How to perform a split in SQL server 2008 r2?

Hi, I wanted to know if it is possible to carry out a split as shown below, since I need to receive a string of words separated by commas; So far I have not been served by the methods I have seen on the internet. SELECT * FROM BASE WHERE Doc i...
asked by 24.11.2016 / 16:00