• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1198
  • 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
Simone BCommented:
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

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

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