Wrox Programmer Forums
|
BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6
This is the forum to discuss the Wrox book Beginning SQL Server 2005 Programming by Robert Vieira; ISBN: 9780764584336
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2006, 04:13 PM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQLCMD

In reading Ch 11 on Scripts and Batches on page 338, Robert Vieira gave a code example at the bottom of the page with the line...

SET @str = 'SELECT LEFT(CompanyName,' + CAST(@NumberOfLetters AS varchar) + ') AS ShortName FROM Customers'

My question is why do you need to use CAST in this case as it seems to me that when you use the LEFT function, you want an integer number to indicate the number of letters you want to select.

Any ideas on this?



Gary









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.