[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VBScript Coding Syntax with SQL query

Posted on 2009-05-13
5
Medium Priority
?
441 Views
Last Modified: 2012-05-06
(Code1 Question) Am using   file.write line   to create row header to output results of sql query to  csv file.
 In the code,  I need to separate the line for readability. Or can I use a str variable instead? How would I do that?

(Code2 Question) Am using     SQL=SQL &    to separate sql query in VBScript. Can I use a str variable instead? How would I do that?

'Code1 Sample:
file.WriteLine ""CLASS"",""SCHOOLNUM"",""SCHLNAME"",""SECTION"",""COURSE"",""TITLE"" "
'would like to separate it: into 2 lines or use a variable. (such as strheader=?)
 
'Code2 Sample:
SQL="select blah, blah, blah, blah....."
SQL=SQL & "blah, blah, blah....."
Can I use  a variable instead? (such as strsql=?)

Open in new window

0
Comment
Question by:lbarnett419
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24375190
First question, to seperate into two lines, can you not just do two write lines?
file.WriteLine ""CLASS"",""SCHOOLNUM"",""SCHLNAME"","
file.WriteLine"SECTION"",""COURSE"",""TITLE"" "


SQL is already a variable!

 
'Code2 Sample:
SQL="select blah, blah, blah, blah....."
SQL=SQL & "blah, blah, blah....."
Can I use  a variable instead? (such as strsql=?)
0
 

Author Comment

by:lbarnett419
ID: 24375550
(1) Will separating into file.writeline 2x keep the entire row intact in the file?

(2) I understand about #2, but can't I declare
strsql="Select blah, blah, blah from table"    
 then use the strsql instead of all the lines of SQL=SQL& I would need with a big query?

Be patient with me; I'm a novice in this area. Thanks
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24375805
(1) Ok, you mean in code you want to write in two lines but show as one line when written?

use .write instead of .writeline

file.write

then end with

file.writeline

(2) Do you mean you want to append a string?
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 24375856
String concatenation can be done using & as you have done

strsql = "xxxx"
strsql = strsql & "yyyy"


Regarding (1)

And example

I use chr(34) to write a double quote

f.Write chr(34) & "CLASS" & chr(34) & "," & chr(34) & "SCHOOLNUM" & chr(34) & "," & 

chr(34)
f.write "SCHLNAME" & chr(34) & "," & "SECTION" & chr(34) & "," & chr(34)
f.writeline "COURSE" & chr(34) & "," & chr(34) & "TITLE"
0
 

Author Closing Comment

by:lbarnett419
ID: 31580982
Thanks
0

Featured Post

Looking for the Wi-Fi vendor that's right for you?

We know how difficult it can be to evaluate Wi-Fi vendors, so we created this helpful Wi-Fi Buyer's Guide to help you find the Wi-Fi vendor that's right for your business! Download the guide and get started on our checklist today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question