Solved

SQL Query

Posted on 2016-08-24
3
23 Views
Last Modified: 2016-08-24
Hello,
I am writing a stored procedure with a query

IF NOT EXISTS( SELECT [Date],[Time],PickUpTime
                          FROM DIY WHERE( [Date] = CONVERT(NVARCHAR(20),@Date,112)  AND  [PickUpTime] = CONVERT(NVARCHAR(16),@PickUpTime,112) AND  [Time] = CONVERT(NVARCHAR(16),@Time,112))      

does not do it correctly on the time conversion any suggestions?

Cheers
0
Comment
Question by:RIAS
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41768489
without concrete data as it is in the table and the variables, impossible to tell for sure

you may want to (re)read this article;:
https://www.experts-exchange.com/articles/1499/DATE-and-TIME-don't-be-scared-and-do-it-right-the-first-time.html
0
 

Author Comment

by:RIAS
ID: 41768513
Any suggestions on how to check for null

example :

[REG] = @[REG]
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 41768577
NULL on which side?

depending on the context, and the possible values and data type of the column/variable, I either use an AND/OR expression or a isnull expresion

AND (  ( [REG] IS NULL AND @[REG] IS NULL )
       OR ( [REG] = @[REG] )
       )

Open in new window

AND (  ISNULL( ( [REG] , 'X$X' ) = ISNULL( @[REG] , 'X$X' ) )

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question