• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1204
  • Last Modified:

SSIS 2005, Adding a comment line

Hi and thanks,

I would like to add a comment line in:
Execute SQL Task - SQLStatement

I have tryed:

-- add comment line
* add comment line
// add comment line
/* add comment line
*/ add comment line

Still I get errors

Please help and thanks
0
Amour22015
Asked:
Amour22015
  • 5
  • 5
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
-- This is a comment line

/*
This is a comment block
*/

So ... copy-paste your 'SQL Task - SQL Statement' into this quetsion.
0
 
Amour22015Author Commented:
jimhorn,


I had this:

-- This table gets deleted
Drop Table [TblError]
GO


And I received an error on:
-- This table gets deleted

Should I have it like:
/*
This table gets deleted
*/
Drop Table [TblError]
GO

Thanks
0
 
Amour22015Author Commented:
jimhorn,


I just tryed and received Error?

Thanks
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
Simone BSenior E-Commerce AnalystCommented:
Any query that runs successfully in Management Studio should run successfully in an Execute SQL task. Try running your query in Mgmt Studio first, including all of your comments, and see if you get any errors. Please post any errors you receive.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The below should work, I removed the square brackets. So spell out the error that you're getting.

-- This table gets deleted
Drop Table TblError
GO

Open in new window


Also, if the table does not exist, dropping it will throw an error, so try this:

-- This table gets deleted
IF OBJECT_ID('TblError') IS NOT NULL
   Drop Table TblError
GO

Open in new window

0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Also, the word GO executes all tasks up to that point, so if this is in the middle of a longer script any variables that were previously declared go away.

So ... You may want to split up the DDL tasks like dropping tables into one SQL task, and the DML tasks that manipulates data in those tasks in the next SQL task.
0
 
Amour22015Author Commented:
jimhorn,

Are you saying if I declare a variable see attachment:
Execute SQL Task

and have a multable sql statements that need the varable.  I can not do it like:

INSERT INTO tblError ( lngCount, strError )
SELECT Count(tblAuto.acct_num) AS CountOfacct_num, "Grant DV based on tag desc" AS Expr1
FROM tblAuto
WHERE (((tblAuto.tag_desc) Like "*Disabled vet*") AND ((tblAuto.bill_end)>[TaxYear]))
GROUP BY tblAuto.decal_typ_ndx
HAVING (((Count(tblAuto.acct_num))>0) AND ((tblAuto.decal_typ_ndx)=1));
GO
UPDATE tblAuto INNER JOIN dbo_auto ON (tblAuto.item = dbo_auto.item) AND (tblAuto.acct_num = dbo_auto.acct_num) SET tblAuto.decal_typ_ndx = 5, dbo_auto.decal_typ_ndx = 5
WHERE (((tblAuto.decal_typ_ndx)=1) AND ((tblAuto.tag_desc) Like "*Disabled vet*") AND ((tblAuto.bill_end)>[TaxYear]));
GO

And have it check for TaxYear?
Wow that would not be nice......


Thanks
Varables.docx
0
 
Amour22015Author Commented:
Hi,


I tryed the:

-- Comment line

and received an error on that line
Error: 0xC002F210 - Task Name, Execute SQL Task: Executing the query "-- Comment line

Need help what am I doing wrong?
Thanks
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Perhaps Script Tasks cannot process comments, remove them and try again.

You can always write an annotation outside of the task.

Also, it might not be able to handle multiple GO statements.

>And have it check for TaxYear?
You'll have to use ? to signify a parameter, then in the Variables section add a variable to feed that parameter.
0
 
Amour22015Author Commented:
Thanks
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now