Francisco H Tapia
my.lists at verizon.net
Mon May 3 16:34:22 CDT 2004
:D, thanks, i was looking to closely at it, and then again, not close enough :D Djabarov, Robert said the following on 5/3/2004 2:05 PM: >You're missing a closed parenthesis after: > SET @LocationName = 'Office ' + CAST(@i AS VARCHAR(3) > >Robert Djabarov >SQL Server & UDB >Sr. SQL Server Administrator >Phone: (210) 913-3148 >Pager: (210) 753-3148 >9800 Fredericksburg Rd. San Antonio, TX 78288 >www.usaa.com > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of >Francisco H Tapia >Sent: Monday, May 03, 2004 3:48 PM >To: dba-sqlserver at databaseadvisors.com >Subject: [dba-SQLServer] Review > >I need to get a 2nd pair of eyes on this... The purpose of this script >is to go into tbl_address and prevent a duplication of the name "main >office" for companyID selected. So far It appears to me as if it's fine > >but I keep getting an error on the Keyword WHILE, what did I miss... >i've been staring at it for 30min :( > >Declare @CompanyID as UniqueIdentifier, @LocationName As Varchar(100) >SET @CompanyID = 'E0979997-E5F1-4DC0-8597-5EB649DEC872' >IF IsNull(@LocationName,'') = '' > BEGIN > IF EXISTS(Select LocationName from tbl_Address WHERE CompanyID = >@CompanyID AND LocationName = 'Main Office') > BEGIN > DECLARE @i AS INT > SET @i = 1 > SET @LocationName = 'Office ' + CAST(@i AS VARCHAR(3) > WHILE EXISTS(Select LocationName from tbl_Address WHERE >CompanyID = @CompanyID AND LocationName = @LocationName) > BEGIN > SET @LocationName = 'Office ' + CAST(@i AS VARCHAR(3) > SET @i = @i + 1 > END > > END > ELSE > BEGIN > SET @LocationName = 'Main Office' > END > END > > > -- -Francisco