Showing posts with label basically. Show all posts
Showing posts with label basically. Show all posts

Wednesday, March 21, 2012

Problems with my database creation script

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?
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

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?
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

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?
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

Tuesday, March 20, 2012

Problems with Multi-column and Footers

I have a multi-column report that I had working fine as of Friday night. It
is basically a two-column report of bar-codes to be read by a scanner, with
some identifying information under each entry.
I then added a Header that picked up a data field using the recommended
method I found in one other entry -- basically, refer to a field on the page
rather than a data base field -- that worked fine, and put a nice header all
of the way across the top of each page.
I then told it to add a footer that had static information across the bottom
of the page. Once I did that, it would no longer print the right
hand-column. It continued to print the header across the top of the page,
the data, all in the left-hand column (on three pages), and the footer
across the complete bottom of each page.
However, try as I might, I was never able to get it to print the barcode in
multiple columns.
Walt Crosby
walt.crosby@.everydaywireless.comAfter reading McGraw-Hill/Osborne's Microsoft SQL Server 2005 Reporting
Services by Brian Larson, I discovered that I was using the wrong body
format. I was using Table when I should have used List. Once I changed my
data type to List, everything worked fine.
I also had gone overboard on making solid outlines around each of the items
in the list. Once I reduced the number of outlines, everything cleaned up.
Walt
"Walt Crosby" <Walt.Crosby@.everydaywireless.com> wrote in message
news:OXxcbb%23OGHA.2268@.TK2MSFTNGP09.phx.gbl...
>I have a multi-column report that I had working fine as of Friday night.
>It is basically a two-column report of bar-codes to be read by a scanner,
>with some identifying information under each entry.
> I then added a Header that picked up a data field using the recommended
> method I found in one other entry -- basically, refer to a field on the
> page rather than a data base field -- that worked fine, and put a nice
> header all of the way across the top of each page.
> I then told it to add a footer that had static information across the
> bottom of the page. Once I did that, it would no longer print the right
> hand-column. It continued to print the header across the top of the page,
> the data, all in the left-hand column (on three pages), and the footer
> across the complete bottom of each page.
> However, try as I might, I was never able to get it to print the barcode
> in multiple columns.
> Walt Crosby
> walt.crosby@.everydaywireless.com
>