Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Using TRIM in SQL SP
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using TRIM in SQL SP

 Post Reply Post Reply
Author
Greaser View Drop Down
Newbie
Newbie


Joined: 30 October 2002
Location: United States
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greaser Quote  Post ReplyReply Direct Link To This Post Topic: Using TRIM in SQL SP
    Posted: 31 July 2003 at 10:36am

I think what I am needing to do is pretty easy I just cant figure out the right syntax and where to place it.  I need to pass a string to my stored procedure.  However it doesn't like characters like . / or :  .  But if I put them into square brackets it will work.  I am going from a form on an ASP page to SQL 2000 through a Stored procedure.  My Data Types are all  VarChar.  I am planning on using the TRIM function to add the [] and then to remove them in SQL unless there is an easier way.  Any help would be appreciated. Please let me know if you need more info. 

Exapmple:

strTime = Request.Form("uTime")

strTime = "[8:28:00]" if I hard code it with [ ] I don't get errors. 

strSQL  = "exec sp_insertStatus " + strType + ", " + StrBuildno + "," + strVer + ", " + strProc  + "," + strStatus + "," + strEta + "," + strTime + "," + strDate + ""

My stored procedure is

CREATE procedure sp_insertStatus
 @vType varchar(20),
 @VBuild varChar(20),
 @vVer varChar(20),
 @vProc varChar(5),
 @vStatus varchar (20),
 @vEta varchar(20),
 @vUtime varchar(20),
 @vUDate varchar(20)

as
declare @vBuildID varchar(9)
if EXISTS

 (
   Select * from tblBuild
 where type = @vtype and BuildNo = @vBuild and ver = @vVer and processor = @vProc
  )

    Begin
set @vBuildID = (Select pk_buildID from tblBuild where type = @vtype and BuildNo = @vBuild and ver = @vVer and processor = @vProc)

insert tblLabinfo
    values (@vBuildID, @vStatus, @vEta, @vUdate, @vUTime)
end

else
   begin
    insert into tblBuild values (@vType,@vBuild,@vVer,@vProc)

set @vBuildID = (Select pk_buildID from tblBuild where type = @vtype and BuildNo = @vBuild and ver = @vVer and processor = @vProc)

insert tblLabinfo
  values (@vBuildID, @vStatus, @vEta, @vUdate, @vUTime)

end
GO

 

Back to Top
Greaser View Drop Down
Newbie
Newbie


Joined: 30 October 2002
Location: United States
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greaser Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 11:29am

NEVER MIND! 

I just needed to add a nother single quote around the quotes.

'"+ strProc  + "'

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.