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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Invoice Cursor

Author  Topic 

NeilG
Aged Yak Warrior

530 Posts

Posted - 2007-03-29 : 08:10:20
Just seeing if people have any suggestions for me on this problem, i am trying to produce some form of invoice for a company and finding that cursors if the best method due to having to format the invoice using sql server. However i have come across a problem in a section where i need to have the invoice address and a shipping address i am finding it hard to sort out the spacing for example

Print ' Invoice address'+' '+' Shipping address '
Print @Customername+' '+@Customername
Print @Address+' '+@ShippingAddress
Print @City+' '+@ShippingCity
Print @PostalCode+' '+@ShippingPostalCode

Now the problem comes that for space reasons I have the datatype for the variables as varchar mainly but when running the report obviously its a problem that it appears disjointed

eg.

Alex Johnson Alex Johnson
16 Stobson Street 16 Stobson Street
Leeds Leeds
LS12 6GH LS12 6GH

Now is there a way that this can be sorted like should I us char() datatype to specify the lengths,

Also is there a command the insert spaces instead of just using the quotation markers ' '


Cheers in advance sql people

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-29 : 08:56:39
"is there a command the insert spaces instead of just using the quotation markers"
You can make use of SPACE() function


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-29 : 10:52:40
Why do you have to format the invoice in SQL Server? How ultimately does this invoice get distributed? Paper? A web page? email ? SQL Server is a database -- it is not designed to format and output reports or invoices. Other tools should be used to present and format and output your data, such as a report writer, Excel, Access, a web page, etc ...

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2007-03-29 : 11:11:41
I need to to run as a cursor inside a stored proc to run off various amounts of invoice to print out on dot matrix print only problem is that i require it to being in the info one at a time and the only way i can see if using a cursor with the fetch next clause....but to be honest i think that i will be looking at other ways now like crystal reports

cheers guys anyway

Neil

You only learn by practice
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-29 : 11:22:14
Yes, please, try to use a better tool if you can. Your life will be much, much easier. And then you also don't need to deal with cursors -- you just use a simple SELECT to return the raw invoice data in a stored procedure, and have the report use that raw data to do all of its formatting. Access, Excel, Reporting Services, Crystal Reports -- all are great tools for doing stuff like this.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -