Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
junior6202
Starting Member
45 Posts |
Posted - 2014-12-10 : 13:01:32
|
I'm new to sql and I am converting an Access query to SQL and one of the filters in the Access view is empty quotes " " . I was curious and I performed a len() function on the column and it return 21. what will be the proper way to display this filter in sql? Thanks in advance. |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-12-10 : 13:21:34
|
please post the entire Access query |
|
|
junior6202
Starting Member
45 Posts |
Posted - 2014-12-10 : 13:57:32
|
SELECT ITEMNMBR,PRBTADCD,DOCDATE, CUSTNMBR, [QUANTITY]*1 AS QTYFROM dbo_SOP10100 INNER JOIN dbo_SOP10200 ON dbo_SOP10100.SOPNUMBE = dbo_SOP10200.SOPNUMBEWHERE ORIGNUMB=" "ORDER BY ITEMNMBR;I want to know what parameter in the Access where statement? |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-12-10 : 14:28:25
|
Then you want:WHERE ORIGNUMB = ' ' double-quotes around string constants become single quotes in SQL Server.Also, this bit looks redundant:[QUANTITY]*1 AS QTY |
|
|
junior6202
Starting Member
45 Posts |
Posted - 2014-12-10 : 14:31:46
|
Thank you for your help. what is the difference between ' ' and null? would you be able to explain it for me. |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-12-10 : 14:46:51
|
null is the absence of any value. In SQL Server (and most RDBMSes), these are true:null <> '' (actually null is not equal to anything)null <> null (to compare two fields for both null, WHERE field1 is null AND field2 is null)Unless you issue this command: SET ANSI_NULLS OFFBut, DON'T DO IT! This will be removed in the future, see: http://msdn.microsoft.com/en-us/library/ms188048.aspx |
|
|
|
|
|