CREATE TABLE U(col1 INT);
INSERT INTO U VALUES(2);
INSERT INTO U VALUES(7);
INSERT INTO U VALUES(9);
CREATE TABLE V(col1 INT);
INSERT INTO V VALUES(3);
INSERT INTO V VALUES(7);
INSERT INTO V VALUES(NULL);
SELECT * FROM U WHERE
col1 NOT IN(SELECT col1 FROM V);
i expected it to return 2 and 9 but it returned nothing. can anyone explain?This is because of NULL value in the V table. Comparing to NULL, we don't
know whether the known values are equal or different, so we have to make an
agreement how to deal in such situations. In your case, you see the result.
If you want to get the values you are mentioning, change the query to
SELECT * FROM U WHERE
U.col1 NOT IN (SELECT V.col1 FROM V WHERE V.col1 IS NOT NULL);
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"ichor" <ichor@.hotmail.com> wrote in message
news:OqZWh2FrFHA.2076@.TK2MSFTNGP14.phx.gbl...
> CREATE TABLE U(col1 INT);
> INSERT INTO U VALUES(2);
> INSERT INTO U VALUES(7);
> INSERT INTO U VALUES(9);
> CREATE TABLE V(col1 INT);
> INSERT INTO V VALUES(3);
> INSERT INTO V VALUES(7);
> INSERT INTO V VALUES(NULL);
>
> SELECT * FROM U WHERE
> col1 NOT IN(SELECT col1 FROM V);
> i expected it to return 2 and 9 but it returned nothing. can anyone
> explain?
>|||If you are using the NOT IN Opereator with a subquery and the subquery
contains any NULL values, the subquery will return NULL!. This can be
dangerous, and this is not the case if you use IN.
http://toponewithties.blogspot.com/...es.blogspot.com
"ichor" <ichor@.hotmail.com> wrote in message
news:OqZWh2FrFHA.2076@.TK2MSFTNGP14.phx.gbl...
> CREATE TABLE U(col1 INT);
> INSERT INTO U VALUES(2);
> INSERT INTO U VALUES(7);
> INSERT INTO U VALUES(9);
> CREATE TABLE V(col1 INT);
> INSERT INTO V VALUES(3);
> INSERT INTO V VALUES(7);
> INSERT INTO V VALUES(NULL);
>
> SELECT * FROM U WHERE
> col1 NOT IN(SELECT col1 FROM V);
> i expected it to return 2 and 9 but it returned nothing. can anyone
> explain?
>|||That exact example is given in Itzik Ben-Gan's T-SQL Black Belt column
this month in SQLMag (Don't Avoid the UNKNOWN
<http://www.windowsitpro.com/Article...47010.html?Ad=1> ).
If you want a fuller explanation, you should read his article.
*mike hodgson*
blog: http://sqlnerd.blogspot.com
Dejan Sarka wrote:
>This is because of NULL value in the V table. Comparing to NULL, we don't
>know whether the known values are equal or different, so we have to make an
>agreement how to deal in such situations. In your case, you see the result.
>If you want to get the values you are mentioning, change the query to
>SELECT * FROM U WHERE
> U.col1 NOT IN (SELECT V.col1 FROM V WHERE V.col1 IS NOT NULL);
>
>|||this is where i took the code from. i have subscribed to sqlmag but cant see
the entire article.
"Mike Hodgson" <mike.hodgson@.mallesons.nospam.com> wrote in message news:OA$
QFNGrFHA.3096@.TK2MSFTNGP15.phx.gbl...
That exact example is given in Itzik Ben-Gan's T-SQL Black Belt column this
month in SQLMag (Don't Avoid the UNKNOWN). If you want a fuller explanation
, you should read his article.
mike hodgson
blog: http://sqlnerd.blogspot.com
Dejan Sarka wrote:
This is because of NULL value in the V table. Comparing to NULL, we don't
know whether the known values are equal or different, so we have to make an
agreement how to deal in such situations. In your case, you see the result.
If you want to get the values you are mentioning, change the query to
SELECT * FROM U WHERE
U.col1 NOT IN (SELECT V.col1 FROM V WHERE V.col1 IS NOT NULL);
Showing posts with label insert. Show all posts
Showing posts with label insert. Show all posts
Friday, March 30, 2012
putting image on Crystal Report
Is there any Facility in Crystal Report 9 to Insert image on Crystal report Dynamically... from Database?
Is there any image/Picture control available
please reply me regarding thisHi!
Followinng is how to load picture in Cr from some path dynamically.
for that you will have to do thid
1. Include Crystal Report Designer in to VB
2. add a picture to Detail section of Report
3. double click Detail seciton and code this
Set Picture1.FormattedPicture = LoadPicture(Filepath)
i have used it with Cr8.5.
Is there any image/Picture control available
please reply me regarding thisHi!
Followinng is how to load picture in Cr from some path dynamically.
for that you will have to do thid
1. Include Crystal Report Designer in to VB
2. add a picture to Detail section of Report
3. double click Detail seciton and code this
Set Picture1.FormattedPicture = LoadPicture(Filepath)
i have used it with Cr8.5.
Friday, March 23, 2012
Push data to remote server
Can I run bulk insert or bcp on a local server to insert data into a
remote server?
What are the other options to Push data to a remote server outside a
firewall?
Bulk insert is only for insert purposes -- you would need to run this on the
remote server. BCP does in/out. In theory you could run this from your
machine (with a file on your PC) and specify the remote server as the
destination.
You might be able to use replication or custom built insert statements that
utilize linked servers for connectivity.
Keith Kratochvil
"Rishi" <mrrishisharma@.gmail.com> wrote in message
news:1159992378.416088.171020@.b28g2000cwb.googlegr oups.com...
> Can I run bulk insert or bcp on a local server to insert data into a
> remote server?
> What are the other options to Push data to a remote server outside a
> firewall?
>
remote server?
What are the other options to Push data to a remote server outside a
firewall?
Bulk insert is only for insert purposes -- you would need to run this on the
remote server. BCP does in/out. In theory you could run this from your
machine (with a file on your PC) and specify the remote server as the
destination.
You might be able to use replication or custom built insert statements that
utilize linked servers for connectivity.
Keith Kratochvil
"Rishi" <mrrishisharma@.gmail.com> wrote in message
news:1159992378.416088.171020@.b28g2000cwb.googlegr oups.com...
> Can I run bulk insert or bcp on a local server to insert data into a
> remote server?
> What are the other options to Push data to a remote server outside a
> firewall?
>
Push data to remote server
Can I run bulk insert or bcp on a local server to insert data into a
remote server?
What are the other options to Push data to a remote server outside a
firewall?Bulk insert is only for insert purposes -- you would need to run this on the
remote server. BCP does in/out. In theory you could run this from your
machine (with a file on your PC) and specify the remote server as the
destination.
You might be able to use replication or custom built insert statements that
utilize linked servers for connectivity.
Keith Kratochvil
"Rishi" <mrrishisharma@.gmail.com> wrote in message
news:1159992378.416088.171020@.b28g2000cwb.googlegroups.com...
> Can I run bulk insert or bcp on a local server to insert data into a
> remote server?
> What are the other options to Push data to a remote server outside a
> firewall?
>
remote server?
What are the other options to Push data to a remote server outside a
firewall?Bulk insert is only for insert purposes -- you would need to run this on the
remote server. BCP does in/out. In theory you could run this from your
machine (with a file on your PC) and specify the remote server as the
destination.
You might be able to use replication or custom built insert statements that
utilize linked servers for connectivity.
Keith Kratochvil
"Rishi" <mrrishisharma@.gmail.com> wrote in message
news:1159992378.416088.171020@.b28g2000cwb.googlegroups.com...
> Can I run bulk insert or bcp on a local server to insert data into a
> remote server?
> What are the other options to Push data to a remote server outside a
> firewall?
>
Push data to remote server
Can I run bulk insert or bcp on a local server to insert data into a
remote server?
What are the other options to Push data to a remote server outside a
firewall?Bulk insert is only for insert purposes -- you would need to run this on the
remote server. BCP does in/out. In theory you could run this from your
machine (with a file on your PC) and specify the remote server as the
destination.
You might be able to use replication or custom built insert statements that
utilize linked servers for connectivity.
Keith Kratochvil
"Rishi" <mrrishisharma@.gmail.com> wrote in message
news:1159992378.416088.171020@.b28g2000cwb.googlegroups.com...
> Can I run bulk insert or bcp on a local server to insert data into a
> remote server?
> What are the other options to Push data to a remote server outside a
> firewall?
>
remote server?
What are the other options to Push data to a remote server outside a
firewall?Bulk insert is only for insert purposes -- you would need to run this on the
remote server. BCP does in/out. In theory you could run this from your
machine (with a file on your PC) and specify the remote server as the
destination.
You might be able to use replication or custom built insert statements that
utilize linked servers for connectivity.
Keith Kratochvil
"Rishi" <mrrishisharma@.gmail.com> wrote in message
news:1159992378.416088.171020@.b28g2000cwb.googlegroups.com...
> Can I run bulk insert or bcp on a local server to insert data into a
> remote server?
> What are the other options to Push data to a remote server outside a
> firewall?
>
Friday, March 9, 2012
Pull down from one table and push up into another....
Hi All,
I have a problem,
I need to copy a large amount of data from one table and insert it into another table.
The design of the destination table is exactly the same as the source table except for the fact that it has one extra field.
Can I copy; in a single SQL statement; all rows in one table (that match given criteria) into another table allowing for the extra field?What's "a large amount of data"?
INSERT INTO myNewTable99(Col1, Col2, ect)
SELECT Col1,Col2,ect
FROM myOldTable99
WHERE ...
You could also create a view, bcp the data out then in...|||OK - i see how that copies the old data across but what about the additional field?|||Oh and by a large amount of data i'm talking about 10,000 rows of data from a table of around 20 fields of various types.|||OK - i see how that copies the old data across but what about the additional field?
Just leave it out of the col list...unless it's not null
Then either add a 0 or '' or '12/31/9999' depending on the data type in the SELECT
and 10,000 is nothing...
I have a problem,
I need to copy a large amount of data from one table and insert it into another table.
The design of the destination table is exactly the same as the source table except for the fact that it has one extra field.
Can I copy; in a single SQL statement; all rows in one table (that match given criteria) into another table allowing for the extra field?What's "a large amount of data"?
INSERT INTO myNewTable99(Col1, Col2, ect)
SELECT Col1,Col2,ect
FROM myOldTable99
WHERE ...
You could also create a view, bcp the data out then in...|||OK - i see how that copies the old data across but what about the additional field?|||Oh and by a large amount of data i'm talking about 10,000 rows of data from a table of around 20 fields of various types.|||OK - i see how that copies the old data across but what about the additional field?
Just leave it out of the col list...unless it's not null
Then either add a 0 or '' or '12/31/9999' depending on the data type in the SELECT
and 10,000 is nothing...
Subscribe to:
Posts (Atom)