Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

went from SQL 2000 to SQL 2008 need help converting this SQL code over

Status
Not open for further replies.

grippy

Programmer
Dec 2, 2004
161
US
Hello all, I just upgraded servers and we are now using sql server 2008 rather than sql server 2000. I have some scripts to convert since they are giving me errors about "Multi-Part Identifier could not be bound". Below is one of my scripts that if I can get to work Im just I can convert the rest that I have. Let me know what you think is wrong guys. Thank you
Code:
DELETE tblPriceGrabberFeed INSERT INTO tblPriceGrabberFeed
                                                                                       (availability, categorization, condition, image_url, manufacturer_name, manufacturer_part_number, price, 
                                                                                       product_description, product_name, product_url, shipping_cost, unique_retailer_id)
                                                                SELECT      'yes' AS availability, 
                                                                                       'Automotive' + ' > ' + tblCompany.name + ' > ' + tblCategoryParts.partsCategory + ' > ' + tblCategoryCompany.companyCategory
                                                                                        AS categorization, 'New' AS condition, 
                                                                                       '[URL unfurl="true"]http://www.domain.com/images/'[/URL] + CASE WHEN tblProduct.image = 0 THEN 'product/medium1/' + REPLACE(tblCompany.name,
                                                                                        ' ', '%20') + '%20' + REPLACE(REPLACE(tblProduct.productName, ' ', '%20'), '-', '%20') 
                                                                                       + '.jpg' WHEN tblProduct.image = 1 THEN 'productSpecific/medium1/' + REPLACE(tblCompany.name, ' ', '%20') 
                                                                                       + '%20' + REPLACE(REPLACE(tblProduct.productCode, ' ', '%20'), '-', '%20') + '.jpg' END AS image_url, 
                                                                                       tblCompany.name AS manufacturer_name, tblProduct.productCode AS manufacturer_part_number, 
                                                                                       tblProduct.salePrice AS price, tblCompany.name + ' ' + tblProduct.productName + ' ' + CONVERT(varchar, 
                                                                                       ISNULL(tblProduct.beginYear, '')) + '-' + CONVERT(varchar, ISNULL(tblProduct.endYear, '')) 
                                                                                       + ' ' + ISNULL(tblCarMake.make, '') + ' ' + ISNULL(tblCarModel.model, '') + ' ' + ISNULL(tblProduct.otherLimiters, '') 
                                                                                       + ' ' + ISNULL(tblProduct.otherText, '') + ' ' + ISNULL(tblProduct.notes, '') 
                                                                                       + ' > ' + tblCategoryCompany.companyCategory + ' > ' + tblCategoryParts.partsCategory + ' ' + tblProduct.productCode AS product_description,
                                                                                        tblCompany.name + ' ' + tblProduct.productName + ' ' + ' ' + ISNULL(tblCarMake.make, '') 
                                                                                       + ' ' + ISNULL(tblCarModel.model, '') + ' ' + ISNULL(tblProduct.otherLimiters, '') + ' ' + CONVERT(varchar, 
                                                                                       ISNULL(tblProduct.beginYear, '')) + '-' + CONVERT(varchar, ISNULL(tblProduct.endYear, '')) 
                                                                                       + ' ' + tblProduct.productCode AS product_name, '[URL unfurl="true"]http://www.gripmotorsports.com/pi~pn~'[/URL] + REPLACE(tblCompany.name, 
                                                                                       ' ', '+') + '+' + REPLACE(tblProduct.productName, ' ', '+') + '+' + REPLACE(tblCarMake.make, ' ', '+') 
                                                                                       + '+' + REPLACE(tblCarModel.model, ' ', '+') + '-' + CONVERT(varchar, tblProduct.ID) + '.html' AS product_url, 
                                                                                       tblProduct.shippingCostSingle AS shipping_cost, tblProduct.ID AS unique_retailer_id
                                                                FROM          tblProduct INNER JOIN
                                                                                       tblCompany ON tblProduct.company = tblCompany.ID INNER JOIN
                                                                                       tblCarMake ON tblProduct.carMake = tblCarMake.ID INNER JOIN
                                                                                       tblCarModel ON tblProduct.carModel = tblCarModel.ID INNER JOIN
                                                                                       tblCategoryCompany ON tblProduct.companyCategory = tblCategoryCompany.ID INNER JOIN
                                                                                       tblCategoryParts ON tblProduct.partsCategory = tblCategoryParts.ID
                                                                WHERE      tblProduct.salePrice IS NOT NULL
 
I suggest to only test the SELECT part of the query. Also, it will be easier to understand this query if you will use aliases for table names and not that hard to read naming convention you're using (tbl prefix really only makes you type more, it doesn't add any value).

Take a look at this blog post
T-SQL best practices

PluralSight Learning Library
 
Try getting rid of the delete statement, or put the insert on a separate line.
You may also need an appropriate separator between the 2 statements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top