SQL

SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a table called "Parameters" in Access 2010 that contains ranges of years by Category. I'm looking for the SQL that would DELETE all records from the "dataTable" where the range of years for each category does NOT fall within the range of years found in the "Parameters" table by category.

Below is a picture of the "Parameters" table and the "dataTable". The records highlighted in RED are the records that would be deleted since they are outside of the "years" range in the "Parameters" table.

Thanks in advance for your help!

table 1
table 2
0
CompTIA Cloud+
LVL 13
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

I Might be overthinking this query…
In the sample below, I am trying to return all 5 columns for each user from the row that has the highest timestamp

USER	ENTRY		COL_C		COL_D	 	COL_E
MIKE	2/13/2019 06:00	123DE		34fDer		EHST6
MIKE	2/14/2019 09:30	94DTE		3578HG  	2342DER
MIKE	2/18/2019 07:32	656TR		3535RE		23FR2
TOM	2/11/2019 11:45	574RE		2738FR		263DR
TOM	2/19/2019 07:26	343WE		3874GF		263WW

Open in new window


Result should be
MIKE      2/18/2019 07:32      656TR            3535RE            23FR2
TOM      2/19/2019 07:26      343WE            3874GF            263WW

I want to select MAX(ENTRY) and group by USER, but to bring back the other 3 columns they need to be in the group by. Because they are all unique values I end up returning all rows.
not sure how to accomplish this
0
I have a table called "Parameters" in Access 2010 that contains a ranges of years by Category that I'd like to retrieve

Parameters table
I have a data table that I'd like to retrieve records from on "years" that fall within the minimum and maximum year range by category on the Parameters table. For example, based upon my parameters, the data highlighted in yellow below is the data that would be retrieved.

Data
I appreciate any recommendations as to what would be the most efficient way to execute this. Ideally, I'd prefer to do this through SQL, but if this can't be achieved in a single query, I'm open to running a VBA function or whatever you think is best.

Thanks in advance for any suggestions!
0
We had a requirement to find which strategy is working by giving scoring for each promotions based on customers who received promotions in last 24 months but we wanted to exclude customers who opened promotions which were  send earlier then last 24 months.
so basically the requirement(Emails sent out in the last 24 months by excluding clicks in the last 24 months)Please tell me how  I can query in SQL server.

Thanks
0
In my SSIS for each loop...
It is grabbing each file in the folder and running the processes
Then moving the file just completed into an archive folder
My problem is that it is running the processes nN times depending on number of files remaining

So... if I start with 8 files...
It inserts the first file 8 times and runs the processes that many times
Moves that file
And then does the next file 7 times
And so in

Any ideas?

SSIS
For Each Loop Properties
0
Keep receiving "Error converting data type nvarchar to float" when dividing two columns. QUOTE_AMOUNT column is set to Float and IC_UDF_ is set to NVARCHAR> when I attempt to convert IC_UDF_001 to float, numeric or INT, I receive the error. The data for both

SELECT        dbo.BA_VIEW_WO_QUOTE.WO_NUMBER, dbo.BA_VIEW_WO_QUOTE.WQ_NUMBER, dbo.PARTS_MASTER.IC_UDF_002 AS FMV, 
                         dbo.BA_VIEW_WO_QUOTE.QUOTE_AMOUNT, CAST(dbo.BA_VIEW_WO_QUOTE.QUOTE_AMOUNT / dbo.PARTS_MASTER.IC_UDF_002 AS NUMERIC)*100 AS FMV1
FROM            dbo.BA_VIEW_WO_QUOTE INNER JOIN
                         dbo.PARTS_MASTER ON dbo.BA_VIEW_WO_QUOTE.PNM_AUTO_KEY = dbo.PARTS_MASTER.PNM_AUTO_KEY

Open in new window

data.csv
Capture.JPG
0
I want to update values in one table 'tblTaxRecs' with information from another table 'tblFees'

tblFees contains two fields 'BRT  Numeric Long Interger' and  'FeeAmount   Numeric Double'

The Pertinent fields in tblTaxRecs' are 'BRT numeric Long Integer', 'TaxYear  Numeric Long Interger', 'FeeAmount  Numeric Double', 'DateRevised Date', 'UserRevised Short TExt'.

For every record in tblTaxRecs with a taxyear of 2018 and matching a BRT in tblFees, I want to replace the 'FeeAmount' with the corresponding FeeAmount in tblFees that matches the BRT in tblTaxRecs.  If possible I also want to stamp each updated record in tblTaxRecs with the current date and time in field 'DateRevised' and the string 'Updt20190318'.
0
Hi,

In current production database of Mcirosoft sql server 2008, we recently performed maintenance activity of truncating log table that consumed 110 gb of storage space.
After truncate job is complete, we ran reorganize task for tables and indexes plus update statistics job on the table and indexes (full scan). The job was successfully complete
Even after performing the above task, the application performance had degraded.  
New to the Microsoft sql server world, please recommend any pointers to improve the performance.

Regards
0
I have created Five action queries in Ms Access 2016 for inserting data that require further manipulation to give correct information , one of the INSERT QUERY see below:

INSERT INTO tblPosAccounts ( QtySold, UnitCost, CostOfSales, SoldID, POSDate, CosAcc, BSIDCos )
SELECT tblPosLineDetails.QtySold, tblPosLineDetails.UnitCost, tblPosLineDetails.CostOfSales, tblPosLineDetails.ItemSoldID, tblPosLineDetails.POSDate, tblPosLineDetails.CosAcc, tblPosLineDetails.BSIDCos
FROM tblPosLineDetails;

The above query works very well if used against Ms Access 2016 table BUT fail to append in MS SQL Server 2016, kindly assist me on this all the links are just super no errors whatsoever. I do not understand this. The SQL Server has the same tables as MS Access.

See what you can do.

Regards

Chris
0
Actual issue :  there is a PF with 5.000.000 records  (reclen 1000 Bytes, but with a BLOB field.) PF occupies about 1,5 TB (!)
A deletion Job deletes older records  periodically. REUSE  is set to *YES.
Problem: BLOB field-size will not be reduced, also if new records have smaller documents (because of optimized application) as in the old, deleted records.

Theoretical solution:  set PF  to RERUSE = *NO,  write new records  - with smaller documents/smaller BLOB-size  on new diskspace, and then do a RGZPFM,
to remove deleted records (with larger BLOBs) may reduces filesize.
But there is not enaugh diskspace for a RGZPFM.
Is there any other solution to reduce unused BLOB-space in a BLOB field ?
(OS400 with V7.3)
0
High-tech healthcare
High-tech healthcare

From AI to wearables, telehealth to genomics to 3D printing — healthcare technology is seeing rapid advancement. Experts believe that this technological advancement will save money and save lives. Healthcare is changing dramatically, and emerging technology drives that change.

I seem to be struggling with the SQL code that I created and needs a few pointers on where I am going wrong. It seems to be caught in an infinite loop. I know it will be obvious once pointed out but its still a learning curve at the moment.

 DECLARE @TOTAL as int
DECLARE @CUSTOMER varchar(8)
DECLARE @PARTNO varchar(20)
DECLARE @CASE_DISCOUNT numeric(18, 2)
DECLARE @OVERRIDE_DISCOUNT numeric(18, 2)


DECLARE @COUNTER as int
SET @COUNTER = 1

SELECT        dbo.MBG110.CUSTOMER, dbo.MBG110.CUSTNAME, dbo.MBG130.SORDNO, dbo.MBG160.CINVOICE, dbo.MBG130.CUSTORDATE, dbo.MBG130.CUSTREQDTE_SOR, dbo.MBG160.CINVDATE,
                         dbo.MBG160.PARTNO_DS4, dbo.MBB010.DESCRIPTION, dbo.MBG160.DESQTY, dbo.MBB010.WEIGHT_ITM, dbo.MBG160.DESQTY * dbo.MBB010.WEIGHT_ITM AS ORDER_WEIGHT,
                         dbo.MBG130.SIINVVAL_SOR
                                     INTO #TempSales
FROM            dbo.MBG110 RIGHT OUTER JOIN
                         dbo.MBG130 ON dbo.MBG110.CUSTOMERLONG = dbo.MBG130.CUSTOMER_SOR LEFT OUTER JOIN
                         dbo.MBG160 ON dbo.MBG130.SORDNO = dbo.MBG160.SORDNO_DES LEFT OUTER JOIN
                         dbo.MBB010 ON dbo.MBG160.PARTNO_DS4 = dbo.MBB010.PARTNO

ALTER TABLE #TempSales ADD Case_Discount numeric(18, 2)
ALTER TABLE #TempSales ADD Override_Discount numeric(18, 2)
ALTER TABLE #TempSales ADD RowId int identity(1,1)

SELECT @TOTAL = COUNT(CUSTOMER) FROM #TempSales

SELECT        dbo.MBN510.PROMOCODE_N51, dbo.MBN510.CUSTOMER_N51, …
0
Hi,

I am working on this page:
https://kroweb.dk/gfdev/gravsten_pk/gravsten/

At the top od my index.php file I have these lines:
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', 1);
?>

<?php
$link = mysqli_connect("mysql60.unoeuro.com", "kroweb_dk", "passsword", "kroweb_dk_db_gravsten");
$link->set_charset("utf8");
 
// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

$id = $_GET[ 'id' ];
$sql = "SELECT id, Sogn, Stift, Provsti, navn, tlf, email, besked FROM gravsten WHERE id = $id"; 
$result = $link->query($sql);
$row = $result->fetch_object();
?>

Open in new window


But when entering the page I get this error message, which I can't figure out how to fix:

Notice: Undefined index: id in /var/www/kroweb.dk/public_html/gfdev/gravsten_pk/gravsten/index.php on line 16

Fatal error: Uncaught Error: Call to a member function fetch_object() on boolean in /var/www/kroweb.dk/public_html/gfdev/gravsten_pk/gravsten/index.php:19 Stack trace: #0 {main} thrown in /var/www/kroweb.dk/public_html/gfdev/gravsten_pk/gravsten/index.php on line 19.

Hope that somebody can lend me a hand with this :)
0
I have created a SQL Server Job that runs a query which I then will email in HTML format. The issue I am experiencing is that when the SQL statement returns a NULL value the resulting table in HTML does not render the cell and the data shifts. Table-Exampes-of-Now-versus-Intende.docx

My goal is to have display a "Blank" in the cell of the table I am emailing when the corresponding value in SQL is NULL. In the embed Word .doc the third employee (Smith) just joined the company and Termination date is NULL in SQL. This is causing the shift of data to the left.






Open in new window

DECLARE @Body NVARCHAR(MAX),
    @TableHead VARCHAR(1000),
    @TableTail VARCHAR(1000)


SET @TableTail = '</table></body></html>' ;
SET @TableHead = '<html><head>' + '<style>'
    + 'td {border: solid black;border-width: 1px;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font: 9px arial} '
    + '</style>' + '</head>' + '<body>' + 'Date and Time: '
    + CONVERT(VARCHAR(50), GETDATE(), 120)
    + ' <br> <table cellpadding=0 cellspacing=0 border=0;>'
       + '<td bgcolor=#669900><b><font size="1" color="white">Employee</font></b></td>'
       + '<td bgcolor=#669900><b><font size="1" color="white">Hire Date</font></b></td>'
         + '<td bgcolor=#669900><b><font size="1" color="white">Termination Date</font></b></td>'
       + '<td bgcolor=#669900><b><font size="1" color="white">Job Title</font></b></td>'
       + '<td bgcolor=#669900><b><font size="1" …
0
working with Oracle Linked server in SSMS 2008R2

do i need a terminator(or something else)  between  OPENQUERY/dynamic sql statements

I have this line of code

TRUNCATE TABLE [dbo].[XREF_HEADER_DETAIL_ORACLE_EXTRACT_2019_STAGING]
begin try

DECLARE @StartDate AS VARCHAR(10) = '07-JAN-19';
DECLARE @EndDate AS VARCHAR(10) = convert(varchar, getdate(), 101);
DECLARE @Statement NVARCHAR(MAX) = N'
    SELECT *
    FROM OPENQUERY(
        XREF_PROD,
        ''SELECT


etcx......  code


EXECUTE sys.sp_executesql @Statement;



end try
BEGIN CATCH  
   select
   ERROR_NUMBER() AS ErrorNumber,
		ERROR_STATE() AS ErrorState,
		ERROR_SEVERITY() AS ErrorSeverity,
		ERROR_PROCEDURE() AS ErrorProcedure,
		ERROR_LINE() AS ErrorLine,
		ERROR_MESSAGE() AS ErrorMessage;
END CATCH



--- do i need additional code here between statements/dynamic sql statements  ?

--- next dynamic sql statement  

TRUNCATE TABLE [dbo].[ORACLE_CUST]


    SELECT *
    FROM OPENQUERY(
        XREF_PROD,
        ''SELECT reportsTor,


code etcccc...

Open in new window



Thanks
fordraiders
0
I have a table dc_split in which I split a bill total of $2000 three ways.
First and second person's share is 33.3333
The last person's share is 33.3334

create table dc_split (fullname varchar(70), billpercent numeric(7,4), billtotal numeric(12,2), theirshare numeric(12,2))

insert into dc_split (fullname, billpercent, billtotal)
values('Lori', 33.3333, 2000)
insert into dc_split (fullname, billpercent, billtotal)
values('Pete', 33.3333, 2000)
insert into dc_split (fullname, billpercent, billtotal)
values('Joey', 33.3334, 2000)

After updating the table to get their total share:
update dc_split set theirshare=billpercent * billtotal/100

The results are that the share for each person is 666.67 which sums up to a total of 2000.01

I need a way of getting their split values instead to be 666.66 for the first two people
and 666.68 for the last person.  So basically for the first two people, theirshare should not
round up and the last person's share should make up the extra 2 cents.

Is there a way to do this in the sql?
0
I have SQL Server 2017 running on a Windows Azure Virtual Machine.
I have an issue with connectivity.
I am getting the following error when attempting to connect using HTTP://serverip/OLAP/msmdump.dll
The error message is
Either a connection cannot be made to the XXX.XXX.XX.XXX server, or Analysis Services is not running on the computer specified.
Client access is over the Internet connections.
SSAS and IIS are on the same server.
The Azure VM was deployed using Resource Manager.
0
Hello Team

I have the following simple sql code within MS Access

SELECT IIf(IsNull([Total]),"Total","Total") AS [DAY], Sum(qrySLBMECom.Total) AS Total
FROM qrySLBMECom;

 What I require is for the results to show a zero value when  'Sum(qrySLBMECom.Total) AS Total' is null.  

I have tried applying IIF(IsNull....etc but I am receiving an error when including these functions.

Thanks in advance.

Dale
0
using REPLACE and RIGHT to delete anything to the right of a decimal. including the decimal
or something else ?


in a Function i have

Declare @Result varchar(Max)
SET @Result = Replace(@Input,'!','')
Return @Result

I have data in a field that looks like  "1.00"
or
1.45677

I need to strip anything to the Right of the decimal.

Thanks
fordraiders
0
call an UPDATE statement
SELECT CASE based on 2  input variables

-- current code --
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


ALTER FUNCTION [dbo].[ReplaceSpecialCharacter]
(
@Input varchar(max),
@Input_Field varchar(100)
)
RETURNS varchar(Max)
AS
BEGIN
Declare @Result varchar(Max)
SET @Result = Replace(@Input,'!','')
SET @Result = Replace(@Result,'@','')
SET @Result = Replace(@Result,'#','')
SET @Result = Replace(@Result,'$','')
SET @Result = Replace(@Result,'%','')
SET @Result = Replace(@Result,'&','')
SET @Result = Replace(@Result,'*','')
SET @Result = REPLACE(@result,' ','')
Return @Result

END

Open in new window


I need to create a SELECT CASE for various input_field conditions

I was trying:

   CASE WHEN @INPUT_FIELD = 'QTY' THEN
SET @Result = Replace(@Input,'!','')
SET @Result = Replace(@Result,'@','')
Return @Result
CASE WHEN @INPUT_FIELD = 'SKU' THEN
SET @Result = Replace(@Input,'!','')
SET @Result = Replace(@Result,'@','')
SET @Result = Replace(@Result,'#','')
SET @Result = Replace(@Result,'$','')
SET @Result = Replace(@Result,'%','')
SET @Result = Replace(@Result,'&','')
SET @Result = Replace(@Result,'*','')
SET @Result = REPLACE(@result,' ','')
Return @Result
ELSE -- 'DO NOTHING'
END

I keep getting the syntax wrong ?


and then call it:
UPDATE programflow.dbo.pricing_detail_test_special
SET target_gp = dbo.ReplaceSpecialCharacter(target_gp),(sku)
  ??



Thanks
fordraiders
0
Exploring SharePoint 2016
LVL 13
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

SQL SSRS subscription fails with "Failure sending mail: An error occurred during rendering of the report.Mail will not be resent."

SQL Standard edition Version 11.3.6020.0

I have 40 SSRS reports that are working and just 2 that give this error, can anyone help?
0
Hi Experts,

I am in need of some help in order to convince manager to agree on designing a table in a normalized manner.

Attaching two versions of the form, the first one is a none normalized version, while the second is in normalize state.
Also attaching how table definitions would be according to each of those forms.

Basically would need a list of advantages vs. disadvantages we are to expect by choosing each path, in this case in particular.

Since users are used to enter data manually in sheets in a weekly bases (similar look to the denormalized version) they have preference on taking that route.

FYI-Table in question is PatientsMedications (posting test data).

Thanks
Untitled.png
Untitled1.png
Untitled2.png
Untitled3.png
0
Hi,

I'm trying to change a Table-Valued Function to improve the performance of a Store Procedure but I can't get the same result.  Can you tell me where I'm going wrong?

Original:

USE [SIGTB_DATA_PROD]
GO

/****** Object:  UserDefinedFunction [dbo].[fun_eess1]    Script Date: 3/12/2019 6:17:19 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


--00
create FUNCTION [dbo].[fun_eess1]
(
    @institucion int ,
    @disa int,
    @red int,
    @mred int
)
RETURNS @tbl TABLE (idlista [int] IDENTITY, institucion [int], disa [int], red [int], mred [int], establecimiento varchar(10))
AS
BEGIN
    IF (@institucion=1)
    BEGIN
        INSERT INTO @tbl ([institucion], [disa], [red], [mred], [establecimiento])
        SELECT DISTINCT [c_institucion], [c_disa], [c_red], [c_microred], [codrenae] FROM [dbo].[RENAE]
        WHERE 
		
		[c_institucion]=@institucion AND [c_disa]=(CASE @disa WHEN -1 THEN [c_disa] ELSE @disa END)
        AND [c_red]=(CASE @red WHEN -1 THEN [c_red] ELSE @red END)
        AND [c_microred]=(CASE @mred WHEN -1 THEN [c_microred] ELSE @mred END)
	END 
    ELSE
    BEGIN
	IF (@institucion=15)
	BEGIN
		INSERT INTO @tbl ([institucion], [disa], [red], [mred], [establecimiento])
        SELECT DISTINCT [c_institucion], [c_disa], [c_red], [c_microred], [codrenae] FROM [dbo].[RENAE]
        WHERE [c_institucion]='1' AND [c_disa]=(CASE @disa WHEN -1 THEN [c_disa] ELSE @disa END)
        AND [c_red]=(CASE @red WHEN -1 THEN [c_red] ELSE @red END)
   

Open in new window

0
strange problem using Oracle Linked server and dynamic sql INSERT date from oracle to sql server.

Overview:
WHEN I Export from oracle using this same code(NOT SQL INSERT )
AFTER i export the data, I  use the Import Wizard in ssms i have no issues importing the data.

However the code below is my dynamic sql code to INSERT the data via this routine..
I keep getting an error message.
ErrorNumber      ErrorState      ErrorSeverity      ErrorProcedure      ErrorLine      ErrorMessage
8114      1           16                          NULL            2                          Error converting data type nvarchar to int.
In sql server here are the field identified as INT:
[NOOFLINEITEMS] [int] NULL,
[MATCHEDROWID] [int] NULL,
[LINEITEMID] [int] NULL,
[LINEITEMRESID] [int] NULL,
[TOTAL_EXPENSE] [int] NULL,
[QUALIFIEDLINES] [int] NULL,
[MANUALMATCH] [int] NULL,
[NOOFBOTHMFGPRESENT] [int] NULL,
[NOOFDESCRIPTION] [int] NULL,
[NOOFGRAINGERSKU] [int] NULL,
[NOOFMFGNAME] [int] NULL,
[NOOFMFGPARTNUMBER] [int] NULL,
[NOOFSPELLERRORMFGNAME] [int] NULL,
[AVGNOOFWORDSPERLINE] [int] NULL,
[AUTOMATCH] [int] NULL,
[ADMINTIME] [int] NULL,
[ADMINLINECONVERSION] [int] NULL,

OTHER FIELD TYPES:
       [PROJECTID] [nvarchar](255) NULL,
      [SUBMITDATE] [datetime] NULL,
      [STARTDATE] [datetime] NULL,
      [AUDITEDDATE] [datetime] NULL,
      [PROJECTTYPE] [nvarchar](50) NULL,
      [PROJECTPROORRE] [nvarchar](50) NULL,
      [ACCOUNTNUMBER] [nvarchar](100) NULL,
      
      [ACCOUNTTYPE] [nvarchar](100) NULL,
      [SKU] [nvarchar](50) NULL,
      …
0
Experts,

Given the following Access Sql, how could I write an additional field that equals the percent of the total?
The code below produces two rows with attributes and dollar amounts. I'd like to add the Percentage of Total column at the end.
P&L Mapping         Entity     Custom1                Account    Amount              PctOfTotal
50GA1                      BU1       BU Subgroup1      COS          25,000,000            25%
56GA1                      BU1       BU Subgroup2      COS          75,000,000            75%

SELECT tblEntityMaster.[P&LMapping], [1tHFMSalesCos].Entity, [1tHFMSalesCos].Custom1, [1tHFMSalesCos].Account, [1tHFMSalesCos].Amount
FROM tblEntityMaster LEFT JOIN 1tHFMSalesCos ON (tblEntityMaster.HFMBaseEntity = [1tHFMSalesCos].Entity) AND (tblEntityMaster.Custom1 = [1tHFMSalesCos].Custom1)
GROUP BY tblEntityMaster.[P&LMapping], [1tHFMSalesCos].Entity, [1tHFMSalesCos].Custom1, [1tHFMSalesCos].Account, [1tHFMSalesCos].Amount
HAVING (((tblEntityMaster.[P&LMapping])<>"N/A") AND (([1tHFMSalesCos].Entity)="ES_08") AND (([1tHFMSalesCos].Account)="COS"));

Open in new window


In addition, there is another line in the table Where Custom1 = "TotC" that has the total of the two values above, its just filtered out.

Thanks
0
Dynamic sql   date  parameters  not working  from  previous openquery statement that was working.

----  insert 2 DATE parameters ---  
DECLARE @StartDate AS VARCHAR(10) = '01-JAN-19';
DECLARE @EndDate AS DATE = GETDATE();
DECLARE @Statement NVARCHAR(MAX) = N'

In the code:
 for openquery this was working fine. i had hard coded the dates in.

    (SELECT *
    FROM
      (SELECT rownum rnum ,
        (to_date(''01/01/2019'',''mm/dd/yyyy'') +rownum -1) dates
      FROM all_objects
      WHERE rownum <= to_date(''03/12/2019'',''mm/dd/yyyy'') - to_date(''01/01/2019'',''mm/dd/yyyy'')
      )
    WHERE TO_CHAR( to_date(''01/01/2019'',''mm/dd/yyyy'') +rnum-1, ''DY'' ) NOT IN ( ''SAT'', ''SUN'' )
ETC..... CODE

SET @Statement = REPLACE(@Statement, '{StartDate}', '''''' + REPLACE(CONVERT(NCHAR(9), @StartDate, 6), ' ', '-') + '''''');
SET @Statement = REPLACE(@Statement, '{EndDate}', '''''' + REPLACE(CONVERT(NCHAR(9), @EndDate, 6), ' ', '-') + '''''');

ETC....CODE

Open in new window


What I need:
The "start date" i need to start from January 1 of current year.
The "end date" i need to start from GETDATE()

The DATE field in oracle  are formatted as   01-JAN-19


Thanks
fordraiders
0

SQL

SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.