Selecting from a table with NULL columns...??

Last Post 18 Apr 2002 01:56 PM by Lincoln. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Lincoln
New Member
New Member

--
18 Apr 2002 01:56 PM
My previous posting on this was not very descriptive of the issue I am having. Using the Northwind.dbo.customers is I issue this select statment:

SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax FROM Northwind.dbo.Customers

I recieve back all values, including NULL fields, from the columns referenced. But, if I issue this select statement that is trying to auto generate Insert statements for the data in the table:

SELECT '
INSERT INTO Northwind.dbo.Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)
VALUES('+CustomerID+', '+CompanyName+', '+ContactName+', ' +ContactTitle+', '+Address+', '+City+', '+Region+', '+PostalCode+', '+Country+', '+Phone+', '+Fax+')
'+'GO'
FROM customers

How do avoid receiving back NULL row values when columns in my select list are NULL?? See the partial result set below.

This is a partial listing of the result set ....:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL

INSERT INTO Northwind.dbo.Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)
VALUES(BOTTM, Bottom-Dollar Markets, Elizabeth Lincoln, Accounting Manager, 23 Tsawassen Blvd., Tsawassen, BC, T2F 8M4, Canada, (604) 555-4729, (604) 555-3745)
GO
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL

INSERT INTO Northwind.dbo.Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)
VALUES(GROSR, GROSELLA-Restaurante, Manuel Pereira, Owner, 5ª Ave. Los Palos Grandes, Caracas, DF, 1081, Venezuela, (2) 283-2951, (2) 283-3397)
GO

INSERT INTO Northwind.dbo.Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)
VALUES(HANAR, Hanari Carnes, Mario Pontes, Accounting Manager, Rua do Paço, 67, Rio de Janeiro, RJ, 05454-876, Brazil, (21) 555-0091, (21) 555-8765)
GO

INSERT INTO Northwind.dbo.Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)
VALUES(HILAA, HILARION-Abastos, Carlos Hernández, Sales Representative, Carrera 22 con Ave. Carlos Soublette #8-35, San Cristóbal, Táchira, 5022, Venezuela, (5) 555-1340, (5) 555-1948)
GO

INSERT INTO Northwind.dbo.Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)
VALUES(HUNGC, Hungry Coyote Import Store, Yoshi Latimer, Sales Representative, City Center Plaza 516 Main St., Elgin, OR, 97827, USA, (503) 555-6874, (503) 555-2376)
GO
NULL
NULL
NULL
NULL
NULL

INSERT INTO Northwind.dbo.Customers(CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax)
VALUES(LAUGB, Laughing Bacchus Wine Cellars, Yoshi Tannamuri, Marketing Assistant, 1900 Oak St., Vancouver, BC, V3F 2K1, Canada, (604) 555-3392, (604) 555-7293)
GO


You are not authorized to post a reply.

Acceptable Use Policy