Wednesday, March 21, 2012
Problems with my database creation script
I have a strange situation.
I must run the same script in SQL 2000 and SQL 2005.
Basically the script does it:
IF THE SQL SERVER IS SQL 2005, IT CREATES A NEW DATABASE AND USE IT,
BUT IF SQL SERVER IS SQL 2000, IT MUST DOES NOTHING.
USE master
GO
--// Create the DATABASE2005 if SQL is version 2005
IF CAST(LEFT(CAST((SERVERPROPERTY('productv
ersion')) as varchar),1)as
int) = 9 --// 8=SQL2000 , 9=SQL2005
BEGIN
IF NOT EXISTS (select * from sysdatabases where name ='DATABASE2005')
CREATE DATABASE DATABASE2005
ELSE
USE DATABASE2005
END
...
...
... // Here I do others things
...
...
...
When I run it on SQL 2005 everithing is perfect, in 2000 it works but
I receive the following error:
Msg 911, Level 16, State 1, Line 8
Could not locate entry in sysdatabases for database 'DATABASE2005'. No
entry found with that name. Make sure that the name is entered
correctly.
This is because the DATABASE2005 will never exists on SQL 2000
Do you know how can I avoid the error message?
ThanksThis is a parse-time message, that is returned whether or not the USE is
executed. Look at this:
if 1=2
use xyz
You'll get the same error about couldn't locate database 'xyz'.
Can you create a database of that name on your SQL 2000 server and just
never use it?
Or can you leave with the error?
--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
<javier.ignacio.villegas@.gmail.com> wrote in message
news:1147982570.826464.93690@.38g2000cwa.googlegroups.com...
> Hi,
> I have a strange situation.
> I must run the same script in SQL 2000 and SQL 2005.
> Basically the script does it:
> IF THE SQL SERVER IS SQL 2005, IT CREATES A NEW DATABASE AND USE IT,
> BUT IF SQL SERVER IS SQL 2000, IT MUST DOES NOTHING.
> USE master
> GO
> --// Create the DATABASE2005 if SQL is version 2005
> IF CAST(LEFT(CAST((SERVERPROPERTY('productv
ersion')) as varchar),1)as
> int) = 9 --// 8=SQL2000 , 9=SQL2005
> BEGIN
> IF NOT EXISTS (select * from sysdatabases where name ='DATABASE2005')
> CREATE DATABASE DATABASE2005
> ELSE
> USE DATABASE2005
> END
> ...
> ...
> ... // Here I do others things
> ...
> ...
> ...
>
> When I run it on SQL 2005 everithing is perfect, in 2000 it works but
> I receive the following error:
> Msg 911, Level 16, State 1, Line 8
> Could not locate entry in sysdatabases for database 'DATABASE2005'. No
> entry found with that name. Make sure that the name is entered
> correctly.
> This is because the DATABASE2005 will never exists on SQL 2000
> Do you know how can I avoid the error message?
> Thanks
>|||you don't have a "begin" i the inner if statement.
if not exists (...)
begin <-- missing|||you shouldn't ever have to create a dummy database.|||You shouldn't 'have to', I was just trying to come up with ways that the OP
could avoid the error message.
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"BurgerKING" <syi916@.gmail.com> wrote in message
news:1147990015.768418.182120@.i40g2000cwc.googlegroups.com...
> you shouldn't ever have to create a dummy database.
>|||Did you test this?
The BEGIN is not needed if there is only one statement. A
BEGIN would yield an error here, because there is no END. Even adding the
BEGIN/END around the inner statement would not fix things (and would be
unnecessary).
The USE dbname is checked at parse time and will give an error no matter how
much flow control logic you use.
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"BurgerKING" <syi916@.gmail.com> wrote in message
news:1147989782.030160.322280@.j73g2000cwa.googlegroups.com...
> you don't have a "begin" i the inner if statement.
> if not exists (...)
> begin <-- missing
>|||Just like being in front of the class all over again ;-)
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:%23DFMopseGHA.3640@.TK2MSFTNGP03.phx.gbl...
> Did you test this?
> The BEGIN is not needed if there is only one statement. A
> BEGIN would yield an error here, because there is no END. Even adding the
> BEGIN/END around the inner statement would not fix things (and would be
> unnecessary).
> The USE dbname is checked at parse time and will give an error no matter
> how much flow control logic you use.
> --
> HTH
> Kalen Delaney, SQL Server MVP
> www.solidqualitylearning.com
>
> "BurgerKING" <syi916@.gmail.com> wrote in message
> news:1147989782.030160.322280@.j73g2000cwa.googlegroups.com...
>|||And you know how much I love that!
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:eoQ7YtseGHA.3792@.TK2MSFTNGP03.phx.gbl...
> Just like being in front of the class all over again ;-)
> "Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
> news:%23DFMopseGHA.3640@.TK2MSFTNGP03.phx.gbl...
>
Problems with my database creation script
I have a strange situation.
I must run the same script in SQL 2000 and SQL 2005.
Basically the script does it:
IF THE SQL SERVER IS SQL 2005, IT CREATES A NEW DATABASE AND USE IT,
BUT IF SQL SERVER IS SQL 2000, IT MUST DOES NOTHING.
USE master
GO
--// Create the DATABASE2005 if SQL is version 2005
IF CAST(LEFT(CAST((SERVERPROPERTY('productv
ersion')) as varchar),1)as
int) = 9 --// 8=SQL2000 , 9=SQL2005
BEGIN
IF NOT EXISTS (select * from sysdatabases where name ='DATABASE2005')
CREATE DATABASE DATABASE2005
ELSE
USE DATABASE2005
END
...
...
... // Here I do others things
...
...
...
When I run it on SQL 2005 everithing is perfect, in 2000 it works but
I receive the following error:
Msg 911, Level 16, State 1, Line 8
Could not locate entry in sysdatabases for database 'DATABASE2005'. No
entry found with that name. Make sure that the name is entered
correctly.
This is because the DATABASE2005 will never exists on SQL 2000
Do you know how can I avoid the error message?
ThanksThis is a parse-time message, that is returned whether or not the USE is
executed. Look at this:
if 1=2
use xyz
You'll get the same error about couldn't locate database 'xyz'.
Can you create a database of that name on your SQL 2000 server and just
never use it?
Or can you leave with the error?
--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
<javier.ignacio.villegas@.gmail.com> wrote in message
news:1147982570.826464.93690@.38g2000cwa.googlegroups.com...
> Hi,
> I have a strange situation.
> I must run the same script in SQL 2000 and SQL 2005.
> Basically the script does it:
> IF THE SQL SERVER IS SQL 2005, IT CREATES A NEW DATABASE AND USE IT,
> BUT IF SQL SERVER IS SQL 2000, IT MUST DOES NOTHING.
> USE master
> GO
> --// Create the DATABASE2005 if SQL is version 2005
> IF CAST(LEFT(CAST((SERVERPROPERTY('productv
ersion')) as varchar),1)as
> int) = 9 --// 8=SQL2000 , 9=SQL2005
> BEGIN
> IF NOT EXISTS (select * from sysdatabases where name ='DATABASE2005')
> CREATE DATABASE DATABASE2005
> ELSE
> USE DATABASE2005
> END
> ...
> ...
> ... // Here I do others things
> ...
> ...
> ...
>
> When I run it on SQL 2005 everithing is perfect, in 2000 it works but
> I receive the following error:
> Msg 911, Level 16, State 1, Line 8
> Could not locate entry in sysdatabases for database 'DATABASE2005'. No
> entry found with that name. Make sure that the name is entered
> correctly.
> This is because the DATABASE2005 will never exists on SQL 2000
> Do you know how can I avoid the error message?
> Thanks
>|||you don't have a "begin" i the inner if statement.
if not exists (...)
begin <-- missing|||you shouldn't ever have to create a dummy database.|||You shouldn't 'have to', I was just trying to come up with ways that the OP
could avoid the error message.
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"BurgerKING" <syi916@.gmail.com> wrote in message
news:1147990015.768418.182120@.i40g2000cwc.googlegroups.com...
> you shouldn't ever have to create a dummy database.
>|||Did you test this?
The BEGIN is not needed if there is only one statement. A
BEGIN would yield an error here, because there is no END. Even adding the
BEGIN/END around the inner statement would not fix things (and would be
unnecessary).
The USE dbname is checked at parse time and will give an error no matter how
much flow control logic you use.
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"BurgerKING" <syi916@.gmail.com> wrote in message
news:1147989782.030160.322280@.j73g2000cwa.googlegroups.com...
> you don't have a "begin" i the inner if statement.
> if not exists (...)
> begin <-- missing
>|||Just like being in front of the class all over again ;-)
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:%23DFMopseGHA.3640@.TK2MSFTNGP03.phx.gbl...
> Did you test this?
> The BEGIN is not needed if there is only one statement. A
> BEGIN would yield an error here, because there is no END. Even adding the
> BEGIN/END around the inner statement would not fix things (and would be
> unnecessary).
> The USE dbname is checked at parse time and will give an error no matter
> how much flow control logic you use.
> --
> HTH
> Kalen Delaney, SQL Server MVP
> www.solidqualitylearning.com
>
> "BurgerKING" <syi916@.gmail.com> wrote in message
> news:1147989782.030160.322280@.j73g2000cwa.googlegroups.com...
>|||And you know how much I love that!
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:eoQ7YtseGHA.3792@.TK2MSFTNGP03.phx.gbl...
> Just like being in front of the class all over again ;-)
> "Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
> news:%23DFMopseGHA.3640@.TK2MSFTNGP03.phx.gbl...
>
Problems with my database creation script
I have a strange situation.
I must run the same script in SQL 2000 and SQL 2005.
Basically the script does it:
IF THE SQL SERVER IS SQL 2005, IT CREATES A NEW DATABASE AND USE IT,
BUT IF SQL SERVER IS SQL 2000, IT MUST DOES NOTHING.
USE master
GO
--// Create the DATABASE2005 if SQL is version 2005
IF CAST(LEFT(CAST((SERVERPROPERTY('productversion')) as varchar),1)as
int) = 9 --// 8=SQL2000 , 9=SQL2005
BEGIN
IF NOT EXISTS (select * from sysdatabases where name ='DATABASE2005')
CREATE DATABASE DATABASE2005
ELSE
USE DATABASE2005
END
...
...
... // Here I do others things
...
...
...
When I run it on SQL 2005 everithing is perfect, in 2000 it works but
I receive the following error:
Msg 911, Level 16, State 1, Line 8
Could not locate entry in sysdatabases for database 'DATABASE2005'. No
entry found with that name. Make sure that the name is entered
correctly.
This is because the DATABASE2005 will never exists on SQL 2000
Do you know how can I avoid the error message?
ThanksThis is a parse-time message, that is returned whether or not the USE is
executed. Look at this:
if 1=2
use xyz
You'll get the same error about couldn't locate database 'xyz'.
Can you create a database of that name on your SQL 2000 server and just
never use it?
Or can you leave with the error?
--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
<javier.ignacio.villegas@.gmail.com> wrote in message
news:1147982570.826464.93690@.38g2000cwa.googlegroups.com...
> Hi,
> I have a strange situation.
> I must run the same script in SQL 2000 and SQL 2005.
> Basically the script does it:
> IF THE SQL SERVER IS SQL 2005, IT CREATES A NEW DATABASE AND USE IT,
> BUT IF SQL SERVER IS SQL 2000, IT MUST DOES NOTHING.
> USE master
> GO
> --// Create the DATABASE2005 if SQL is version 2005
> IF CAST(LEFT(CAST((SERVERPROPERTY('productversion')) as varchar),1)as
> int) = 9 --// 8=SQL2000 , 9=SQL2005
> BEGIN
> IF NOT EXISTS (select * from sysdatabases where name ='DATABASE2005')
> CREATE DATABASE DATABASE2005
> ELSE
> USE DATABASE2005
> END
> ...
> ...
> ... // Here I do others things
> ...
> ...
> ...
>
> When I run it on SQL 2005 everithing is perfect, in 2000 it works but
> I receive the following error:
> Msg 911, Level 16, State 1, Line 8
> Could not locate entry in sysdatabases for database 'DATABASE2005'. No
> entry found with that name. Make sure that the name is entered
> correctly.
> This is because the DATABASE2005 will never exists on SQL 2000
> Do you know how can I avoid the error message?
> Thanks
>|||you don't have a "begin" i the inner if statement.
if not exists (...)
begin <-- missing|||you shouldn't ever have to create a dummy database.|||You shouldn't 'have to', I was just trying to come up with ways that the OP
could avoid the error message.
--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"BurgerKING" <syi916@.gmail.com> wrote in message
news:1147990015.768418.182120@.i40g2000cwc.googlegroups.com...
> you shouldn't ever have to create a dummy database.
>|||Did you test this?
The BEGIN is not needed if there is only one statement. A
BEGIN would yield an error here, because there is no END. Even adding the
BEGIN/END around the inner statement would not fix things (and would be
unnecessary).
The USE dbname is checked at parse time and will give an error no matter how
much flow control logic you use.
--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"BurgerKING" <syi916@.gmail.com> wrote in message
news:1147989782.030160.322280@.j73g2000cwa.googlegroups.com...
> you don't have a "begin" i the inner if statement.
> if not exists (...)
> begin <-- missing
>|||Just like being in front of the class all over again ;-)
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:%23DFMopseGHA.3640@.TK2MSFTNGP03.phx.gbl...
> Did you test this?
> The BEGIN is not needed if there is only one statement. A
> BEGIN would yield an error here, because there is no END. Even adding the
> BEGIN/END around the inner statement would not fix things (and would be
> unnecessary).
> The USE dbname is checked at parse time and will give an error no matter
> how much flow control logic you use.
> --
> HTH
> Kalen Delaney, SQL Server MVP
> www.solidqualitylearning.com
>
> "BurgerKING" <syi916@.gmail.com> wrote in message
> news:1147989782.030160.322280@.j73g2000cwa.googlegroups.com...
>> you don't have a "begin" i the inner if statement.
>> if not exists (...)
>> begin <-- missing
>|||And you know how much I love that!
--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:eoQ7YtseGHA.3792@.TK2MSFTNGP03.phx.gbl...
> Just like being in front of the class all over again ;-)
> "Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
> news:%23DFMopseGHA.3640@.TK2MSFTNGP03.phx.gbl...
>> Did you test this?
>> The BEGIN is not needed if there is only one statement. A
>> BEGIN would yield an error here, because there is no END. Even adding the
>> BEGIN/END around the inner statement would not fix things (and would be
>> unnecessary).
>> The USE dbname is checked at parse time and will give an error no matter
>> how much flow control logic you use.
>> --
>> HTH
>> Kalen Delaney, SQL Server MVP
>> www.solidqualitylearning.com
>>
>> "BurgerKING" <syi916@.gmail.com> wrote in message
>> news:1147989782.030160.322280@.j73g2000cwa.googlegroups.com...
>> you don't have a "begin" i the inner if statement.
>> if not exists (...)
>> begin <-- missing
>>
>sql
Monday, March 12, 2012
Problems with FTP Task
I've managed to get the connection to point to the proper directory, but every time I attempt to run the package I receive a file not found error. If I change the remotepath variable to a static file instead of an expression I do not receive an error.
Any help would be greatly appreciated as I'm losing my mind on this one.
Thanks
Where are you building the expression for the variable?|||Within the variable properties window of BIDS. I set EvaluateAsExpression to true, when I check the parameter on the values portion of the properties window it looks correct.
|||What OS is the FTP server running?|||Near as I can tell Unix, from what I've been reading it's looking like I have to find another way around the problem.
|||
E_DJ wrote:
Near as I can tell Unix, from what I've been reading it's looking like I have to find another way around the problem.
If it's Unix, then yeah, you'll have to implement FTP using the script task.|||Thanks for your help, do you know if MS has any sort of plan to deal with this issue or is it like most things where we're going to have to wait for the next release before anything is addressed?
|||Let's see:
[Microsoft follow-up]
MSFT - When do you plan on fixing the FTP Task when used against non-Microsoft FTP servers?|||
You said "I'm trying to use a variable and an expression to set the filename at runtime".
Can you give me a little more information how you are setting the variable and expression? I just want to make sure I understand your problem.
Also, what's the error message(s)? Thanks.
|||
Cho Yeung - msft wrote:
You said "I'm trying to use a variable and an expression to set the filename at runtime".
Can you give me a little more information how you are setting the variable and expression? I just want to make sure I understand your problem.
Also, what's the error message(s)? Thanks.
Cho, forget about the variable and expression. The issue here is FTP Task support for non-Microsoft FTP servers.
|||
Cho Yeung - msft wrote:
You said "I'm trying to use a variable and an expression to set the filename at runtime".
Can you give me a little more information how you are setting the variable and expression? I just want to make sure I understand your problem.
Also, what's the error message(s)? Thanks.
Specifically, the problem lies in the requirement to have a leading "/" on all remote file paths. This isn't correct and should be removed.
Connect items already out there:
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=281893
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=150196
http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=125356
Basically, having the leading "/" requirement and then implementing a change directory to that "/" can cause the FTP Task to fail because it cannot find the file (because you've changed to the FTP root instead of the logged-in user's root path). Instead, I propose you guys look into the following: First, don't change directories. Second STOP running a directory listing to compare the file requested to the returned list. (Why? Because based on some of the Connect submissions above, the task doesn't know how to parse it.) PLEASE, just implement an FTP task that submits the commands directly instead of trying to make an "intelligent" FTP Task.
[Microsoft follow-up]
|||I am asking because the original post says
" If I change the remotepath variable to a static file instead of an expression I do not receive an error."
It sounds to me like the package is working if the file is specified explicitly.
|||That is the case, and hence the question, doesn't really make a whole lot of sense as to why it wasn't working.
I know it's not a directory change issue, I took into account that the actual path on the FTP doesn't match the path I see when I log on via the command prompt, once I worked out the filepath from the root dir it fixed that problem.
This is a bit of a moot point now, I wrote a script task to do what I needed it to. Little odd that it took me a half hour to get something working writing a script that took several hours to get to the same point using the FTPTask component.
|||I am going to log a bug in our system so we can track this potential problem.