Link to home
Start Free TrialLog in
Avatar of SmashAndGrab
SmashAndGrab

asked on

How to NOT reference database in SQL statement (SSIS package)

Hi,

I have created an SSIS package that contains SQL statement blocks (see image).

User generated image
My question is:

How do I remove the reference to the database name from within the SQL statement?  I am already using a connection.

I tried copying the SQL code that is in the drop table SQL but I keep getting an error.

 User generated image
Current:

INSERT INTO ServeMe_PROD.dbo.change_request
SELECT * FROM ServeMe_PROD.dbo.change_request_temp

New:

INSERT INTO [dbo].change_request
SELECT * FROM  [dbo].change_request_temp
GO


It doesn't work at the moment and I'm not sure why.

Hope someone can help.

Thanks

Stuart
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try put a semicolon ; after your insert statement?

INSERT INTO change_request ;
SELECT * FROM  change_request_temp

what error was returned here?
Avatar of SmashAndGrab
SmashAndGrab

ASKER

Does it not need the [dbo]?

This statement works perfectly..

drop table [dbo].[incident_temp]
GO
[Execute SQL Task] Error: Executing the query "INSERT INTO ServeMe_PROD.dbo.incident;
SELECT * FR..." failed with the following error: "Incorrect syntax near ';'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
[Execute SQL Task] Error: Executing the query "INSERT INTO dbo.incident;
SELECT * FROM dbo.incide..." failed with the following error: "Incorrect syntax near ';'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
The above error (2nd one) is caused when I run this...

INSERT INTO dbo.incident;
SELECT * FROM dbo.incident_temp
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial