Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
belcherman
Starting Member
5 Posts |
Posted - 2007-12-14 : 21:52:46
|
| I am trying to write a to do the following below:The printed check file has a name that looks like this: <removed>.PDF.In the example name above, <removed> is the check number, <removed> is the routing number and <removed> is the account number.The letters define the piece of data that follows. A = Check number B = Routing number C = Account number Steps: a. stored procedure to pull the check number, routing number and account number from tblCheckRegister. b. Join them together in proper format. b. Once it has done that, do a wildcard search on a table called tblSIValidate column SIBarCode. c. The return value should be the entire SIBarCode column. Append the .PDF to it and look in the same image directory as the cancelled check.I am used to VB.net and vbscripting and the syntax there. I am sure there are things below in the stored procedure that are not correct. Any help is appreciated. ---------------------------------------------------------------STORED PROCEDURE---------------------------------------------------------------/*Name: usp_GetCheckImageDescription: Gets Printed CheckAuthor: MikeModification Log: ChangeDescription Date Changed ByCreated procedure 12/15/2007 Mike Belcher*/CREATE PROCEDURE dbo.rx_bhd_GetCheckImage @maillogid int, PrintedCheckFile OUTPUTASSET NOCOUNT ON/* Get Check#, Routing#, and Account# */SELECT CheckNo, CPRoutingNumber, CPAccountIDFROM tblCheckRegisterWHERE maillogid = @maillogid/* Combine Check#, Routing#, and Account# into proper format */declare @PrintedCheck char(255)@PrintedCheck = "a"@PrintedCheck = "A"@PrintedCheck = @PrintedCheck & CheckNo@PrintedCheck = @PrintedCheck & "B"@PrintedCheck = @PrintedCheck & CPRoutingNumber@PrintedCheck = @PrintedCheck & "C"@PrintedCheck = @PrintedCheck & PAccountID/*if @PrintedCheck = null Give dummy value*/ /* Search tblSIValidate column SIBarCode combined PrintedCheck# Example: "<removed>" */SELECT SIBarCodeFROM tblSIValidateWHERE SIBarCode LIKE @PrintedCheck/* Need to return the @PrintedCheckFile */SET @PrintedCheckFile = SIBarCode & ".pdf"GO |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-12-14 : 22:59:19
|
there are syntax errors in this. Did you try running this script? elsasoft.org |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-12-15 : 23:02:30
|
just noticed there is a real and valid bank routing number for a bank in maryland in the above post. first, for the moderators: someone might want to edit the OP to remove these pieces:1. routing number2. check number3. bank acct numbersecond, for the OP: wtf? elsasoft.org |
 |
|
|
belcherman
Starting Member
5 Posts |
Posted - 2007-12-19 : 17:00:21
|
| They are fake numbers |
 |
|
|
belcherman
Starting Member
5 Posts |
Posted - 2007-12-19 : 17:03:55
|
| they are fake numbers |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
|
|
belcherman
Starting Member
5 Posts |
Posted - 2007-12-21 : 18:10:28
|
| Maybe I should play the lotto. If I could use that talent for making up numbers and win I would be able to retire. I am almost having this work. I still have one issue left.Manually doing a query in SQL server itself produces a result for the following:SELECT SIBarCodeFROM tblValidateWHERE (SIBarCode LIKE '%A11111B222222222C3333333333%')But in the stored procedure no result is returned.@PrintedCheck does have value like the folowing A11111B222222222C3333333333 in the manual search.declare @PrintedCheckBuild char(255)SELECT @PrintedCheckBuild=SIBarCodeFROM tblValidateWHERE SIBarCode LIKE '%' + @PrintedCheck + '%'/* Need to return the @PrintedCheckFile */SET @PrintedCheckFile = @PrintedCheckBuildAny ideas why the same query would return results in SQL QUERY and not in the stored procedure?Thanks. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-12-21 : 22:45:16
|
| Use varchar instead of char for your declare.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|
|
|
|