Showing posts with label proper. Show all posts
Showing posts with label proper. Show all posts

Monday, March 26, 2012

Proper Way to Truncate Log After Performing Full Backup (SQL Server 2000)

Hello all - I have a SQL Server 2000 database setup using the Full Recovery Model. Each night, we backup the entire database, and as such would like to truncate the log at this time as well.

Is the best way to do this to also backup the Transaction Log, and then perform a DBCC SHRINKFILE command? It just seems like there should be an easier way...?

Thanks!

Let's back up a few steps here.

What are you gaining by shrinking the transaction log every night?

The transaction log is designed to continually reuse its space internally. Whenever you back up the transaction log, all virtual log files (logical areas within the physical log file) which are not involved in any current transaction are marked as "free" and can be reused.

So, one way to manage the growth of a transaction log is to vary the frequency of log backups. The more frequent the log backup, the less data needs to be stored in the log (and the less data is lost in the event of a disaster).

Once the log reaches a steady-state, it shouldn't grow unless some exceptional update happens.

When you continually shrink and grow the file, you end up with filesystem fragmentation, which isn't good for performance. Also, the log file growth itself takes time.

proper way to set parameters programatically?

What is the proper way to set a parameter collection's values in code? (C#
or VB.NET) should you get the parameter list using getReportParameters from
the SOAP web service then setting the items in the returned collection then
passing the collection back through setreportparameters..... or can you
just pass a list of programatically created values and names though the
setReportParaemters with out having to get the initial list (say if you
already know the parameters required) thanks!See the examples using parameters here:
http://msdn2.microsoft.com/en-us/library/aa258532(sql.80).aspx
This applies to the render method, which I'm not sure if you'll use or
not, but I think this should give you an idea of what to do.
Smokey Grindle wrote:
> What is the proper way to set a parameter collection's values in code? (C#
> or VB.NET) should you get the parameter list using getReportParameters from
> the SOAP web service then setting the items in the returned collection then
> passing the collection back through setreportparameters..... or can you
> just pass a list of programatically created values and names though the
> setReportParaemters with out having to get the initial list (say if you
> already know the parameters required) thanks!

Proper way to rename ASPNETDB.MDF? Custom provider the solution?

ASP.NET 2.0...

What is the proper way to rename the ASPNETDB.MDF to another name, such as TEST_ASPNETDB.MDF?

I know you can rename the db in the IDE, BUT, there are other places you need to change so that ASPNETDB.MDF isn't recreated. Do I have to make a custom SQLExpress provider or something to that effect?

Any examples? Thanks...

Change the connection strings in web.config:

<?xmlversion="1.0"?>

<configuration>

<connectionStrings>

<clear/>

<addname="LocalSqlServer"connectionString="Data Source={Machine name};Initial Catalog=TEST_ASPNETDB;{Rest of connect string here}"providerName="System.Data.SqlClient"/>

</connectionStrings>

proper way to drop publication?

Hi There

According to BOL, the correct procedure for deleting a publication are as follows:
These must be run on the publication database.

    Execute sp_dropsubscription to delete all snapshot subscriptions.

    Execute sp_droppublication to delete the publication and all of its articles.

My only issue is after step 1 the subscription still exists at the subscriber and it marked as failed (does not exist), i always have to go delete the subscription afterwards at the subscriber. AM i missing something? WHy does sp_dropsubscription not do this? Or is there another sp i should be running first?

Thanx

Hi Dietz,

The actual step to cleanup subscription depending on the subscription is push or pull. Basically, for push, you need to call sp_dropsubscription at publisher followed by sp_subscription_cleanup at subscriber. For Pull, you need to call sp_droppullsubscription at subscriber followed by sp_dropsubscription at pubisher.

Please refer to BOL topic "How to: Delete a Pull Subscription (Replication Transact-SQL Programming)" and "How to: Delete a Push Subscription (Replication Transact-SQL Programming)".

Thanks,|||Great thanx Peng, i wonder why they do not mention any of those sp's under the How to Delete Publications and Articles (Transact-SQL) BOL topic.
Also i cannot find

"How to: Delete a Pull Subscription (Replication Transact-SQL Programming)" and "How to: Delete a Push Subscription (Replication Transact-SQL Programming)".in BOL only TSQL references not Replication Transact sql programming.

I am using SS2000 not SS2005?

Thanx again|||Sorry, dietz. I made a bad assumption to think your system is SQL 2005. Sad My previous post really means for SQL 2005.

In SQL 2000 BOL, there is similar topic on how to drop subscription, depending on pull/push of the subscription. You probably already see it in "How To"->"Transact SQL" section.

Peng
sql

Proper way to backup and restore Broker-Enabled database

For developers, we often have a need to backup a production database and restore it on local or integration machines. This production database is enabled for service broker and operates at a relatively high traffic level. When the database is backed up, the size is nearly 12GB; when SET NEW_BROKER is subsequently executed on the restored database, the size goes down to about 800MB. It appears that most of this is residing in the xmit queue. So, my question is: how best to backup a production database with queues activated, etc. without ending up with a 12GB backup?

Thanks.

There is no way to back up the database without saving the data. A full backup is all or nothing. If you want to shrink the database, as you say, you need to do the post-processing step of NEW_BROKER. If other folks need to use the database, you should always be doing NEW_BROKER. There should not be more than one copy of a database with the same broker instance ID running.

-mike

|||Move your production data into a separate filgroup and backup only that filegroup. The Service Broker xmit queue will always reside on the primary filgroup.

Proper way to backup and restore Broker-Enabled database

For developers, we often have a need to backup a production database and restore it on local or integration machines. This production database is enabled for service broker and operates at a relatively high traffic level. When the database is backed up, the size is nearly 12GB; when SET NEW_BROKER is subsequently executed on the restored database, the size goes down to about 800MB. It appears that most of this is residing in the xmit queue. So, my question is: how best to backup a production database with queues activated, etc. without ending up with a 12GB backup?

Thanks.

There is no way to back up the database without saving the data. A full backup is all or nothing. If you want to shrink the database, as you say, you need to do the post-processing step of NEW_BROKER. If other folks need to use the database, you should always be doing NEW_BROKER. There should not be more than one copy of a database with the same broker instance ID running.

-mike

|||Move your production data into a separate filgroup and backup only that filegroup. The Service Broker xmit queue will always reside on the primary filgroup.

Proper use of the Right Function

RIGHT(value, numberofchars)
select right(username, 6) from ...
Seems like a reference to Books Online would have done this for you much
more efficiently than a forum post. :-)
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"fiaola" <fiaola@.mail.com> wrote in message
news:O9fJ6tLVIHA.5448@.TK2MSFTNGP04.phx.gbl...
> Hi,
> I tried to use the right function as, "Select right(UserName) as UN from
> Table1" and it returned "blank".
> It works well with Left. Im puzzled.
> Thanks
>
"fiaola" <fiaola@.mail.com> wrote in message
news:uIiqWJuVIHA.1184@.TK2MSFTNGP04.phx.gbl...
> Thanks for the reply. I did that, but it returned blank values. If i
> tried the LEFT function, it works well.
> My field is a character, and I could not figure out why it does not pickup
> the parameters requested.
>
What is the username you're using?
Perhaps the 6 right most characters are blank?
Can you post the actual code.
Thanks.

> "TheSQLGuru" <kgboles@.earthlink.net> wrote in message
> news:13ogib06s428b79@.corp.supernews.com...
>
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html

Proper use of the Right Function

Hi,
I tried to use the right function as, "Select right(UserName) as UN from
Table1" and it returned "blank".
It works well with Left. Im puzzled. :)
ThanksRIGHT(value, numberofchars)
select right(username, 6) from ...
Seems like a reference to Books Online would have done this for you much
more efficiently than a forum post. :-)
--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"fiaola" <fiaola@.mail.com> wrote in message
news:O9fJ6tLVIHA.5448@.TK2MSFTNGP04.phx.gbl...
> Hi,
> I tried to use the right function as, "Select right(UserName) as UN from
> Table1" and it returned "blank".
> It works well with Left. Im puzzled. :)
> Thanks
>|||Thanks for the reply. I did that, but it returned blank values. If i tried
the LEFT function, it works well.
My field is a character, and I could not figure out why it does not pickup
the parameters requested.
"TheSQLGuru" <kgboles@.earthlink.net> wrote in message
news:13ogib06s428b79@.corp.supernews.com...
> RIGHT(value, numberofchars)
> select right(username, 6) from ...
> Seems like a reference to Books Online would have done this for you much
> more efficiently than a forum post. :-)
> --
> Kevin G. Boles
> Indicium Resources, Inc.
> SQL Server MVP
> kgboles a earthlink dt net
>
> "fiaola" <fiaola@.mail.com> wrote in message
> news:O9fJ6tLVIHA.5448@.TK2MSFTNGP04.phx.gbl...
>> Hi,
>> I tried to use the right function as, "Select right(UserName) as UN from
>> Table1" and it returned "blank".
>> It works well with Left. Im puzzled. :)
>> Thanks
>|||"fiaola" <fiaola@.mail.com> wrote in message
news:uIiqWJuVIHA.1184@.TK2MSFTNGP04.phx.gbl...
> Thanks for the reply. I did that, but it returned blank values. If i
> tried the LEFT function, it works well.
> My field is a character, and I could not figure out why it does not pickup
> the parameters requested.
>
What is the username you're using?
Perhaps the 6 right most characters are blank?
Can you post the actual code.
Thanks.
> "TheSQLGuru" <kgboles@.earthlink.net> wrote in message
> news:13ogib06s428b79@.corp.supernews.com...
>> RIGHT(value, numberofchars)
>> select right(username, 6) from ...
>> Seems like a reference to Books Online would have done this for you much
>> more efficiently than a forum post. :-)
>> --
>> Kevin G. Boles
>> Indicium Resources, Inc.
>> SQL Server MVP
>> kgboles a earthlink dt net
>>
>> "fiaola" <fiaola@.mail.com> wrote in message
>> news:O9fJ6tLVIHA.5448@.TK2MSFTNGP04.phx.gbl...
>> Hi,
>> I tried to use the right function as, "Select right(UserName) as UN from
>> Table1" and it returned "blank".
>> It works well with Left. Im puzzled. :)
>> Thanks
>>
>
Greg Moore
SQL Server DBA Consulting Remote and Onsite available!
Email: sql (at) greenms.com http://www.greenms.com/sqlserver.html

Proper use of Inner Join with nested select?

ok, i am a novice w/ sql queries, so this will probably be cake for
most of you if i can explain it properly.
I am trying to run a query against 2 tables, tbPlayers and tbResults
that are joined one to many by a PlayerId field. This query is used to
retrieve standings of poker tournament results, 1 record for each
player, an sum of money won from all tournaments, and a count of how
many times they have won any amount of money from a tournament.
SELECT tbPlayers.Name,
Sum(tbResults.MoneyWon) as [Prize Money]
(Select Count(MoneyWon) FROM tbResults WHERE MoneyWon > 0) as Cashes
FROM tbPlayers
INNER JOIN tbResults on tbResults.PlayerId = tbPlayers.Id
GROUP BY Players.Name
This query runs, but the value retrieved for 'Cashes' is incorrect, as
it brings back the count of ALL records in the table instead of just
those associated with a singe PlayerId.
Any thoughts would be greatly appreciated! (and i'll happily offer up a
free version of my Poker Tournament Director application once its ready
for beta ... which is soon!)Try something like this:
declare @.Player table (PlayerId int, name varchar(20))
insert @.Player values (1, 'jeff')
insert @.Player values (2, 'ed')
declare @.Results table (PlayerId int, MoneyWon int )
insert @.Results values(1, 100)
insert @.Results values(1, 0)
insert @.Results values(1, 1000)
insert @.Results values(2, -100)
insert @.Results values(2, 50)
SELECT p.Name,
Sum(r.MoneyWon) as [Prize Money],
Sum(case when MoneyWon > 0 then 1 else 0 end) as Cashes
FROM @.Player p
INNER JOIN @.Results r on p.PlayerId = r.PlayerId
GROUP BY p.Name|||Perfect!! Thank you - you the man!|||BriskDuck@.gmail.com wrote:
> ok, i am a novice w/ sql queries, so this will probably be cake for
> most of you if i can explain it properly.
> I am trying to run a query against 2 tables, tbPlayers and tbResults
> that are joined one to many by a PlayerId field. This query is used to
> retrieve standings of poker tournament results, 1 record for each
> player, an sum of money won from all tournaments, and a count of how
> many times they have won any amount of money from a tournament.
> SELECT tbPlayers.Name,
> Sum(tbResults.MoneyWon) as [Prize Money]
> (Select Count(MoneyWon) FROM tbResults WHERE MoneyWon > 0) as Cashes
> FROM tbPlayers
> INNER JOIN tbResults on tbResults.PlayerId = tbPlayers.Id
> GROUP BY Players.Name
> --
> This query runs, but the value retrieved for 'Cashes' is incorrect, as
> it brings back the count of ALL records in the table instead of just
> those associated with a singe PlayerId.
> Any thoughts would be greatly appreciated! (and i'll happily offer up a
> free version of my Poker Tournament Director application once its ready
> for beta ... which is soon!)
>
Try this :
SELECT tbPlayers.Name,
Sum(tbResults.MoneyWon) as [Prize Money],cashes.[WinCount]
FROM tbPlayers
INNER JOIN tbResults on tbResults.PlayerId = tbPlayers.Id
INNER JOIN (SELECT [PlayerId],COUNT([MoneyWon]) AS [WinCount] FROM
tbResults GROUP BY [PlayerId]) AS Cashes ON tbResults.[PlayerId] =
cashes.[PlayerId]
GROUP BY tbPlayers.Id,tbPlayers.[Name],cashes.WinCount
-JayDial|||JeffB wrote:
> Try something like this:
>
> declare @.Player table (PlayerId int, name varchar(20))
> insert @.Player values (1, 'jeff')
> insert @.Player values (2, 'ed')
> declare @.Results table (PlayerId int, MoneyWon int )
> insert @.Results values(1, 100)
> insert @.Results values(1, 0)
> insert @.Results values(1, 1000)
> insert @.Results values(2, -100)
> insert @.Results values(2, 50)
> SELECT p.Name,
> Sum(r.MoneyWon) as [Prize Money],
> Sum(case when MoneyWon > 0 then 1 else 0 end) as Cashes
> FROM @.Player p
> INNER JOIN @.Results r on p.PlayerId = r.PlayerId
> GROUP BY p.Name
>
Whoa nevermind, forget mine. This looks much better! ;)sql

Proper use of IF statement in stored procedure?

I'm trying to handle a stored procedure parameter. What needs to happen is that a particular statement shouldn't be executed if the parameter is empty. However, when I try it I get the following error:

Cannot use empty object or column names. Use a single space if necessary.

So, what's the correct way of doing the following?

IF @.filename <> ""
BEGIN
UPDATE Experimental_Images SET contentType = @.contentType, filename = @.filename WHERE (id = @.iconNo)
ENDThe problem you are having is that you are using double quotes when youshould be using single quites. The rest of your statements are fine.

What do you mean exactly by "if the parameter is empty". If youmean if it contains an empty string or a NULL, try it like this:

IF ISNULL(@.filename,'') <> ''

If you mean it contains a NULL, try this:
IF @.filename IS NOT NULL

And if you mean it contains an empty string, try it like this:
IF @.filename <> ''

Proper use of Event Notifications

Hi.

I'm developing an app that uses Service Broker queues to allow a customer to create "events" that fire using a timer or a query notification. When these events fire, a message is sent to a Service Broker queue for processing. Because there is much managed code involved in processing these messages, I decided to use the External Activator application and an Event Notification to process these messages. My question is "what is the difference between using the External Activator application to launch another application (which simply RECEIVEs a message from the target queue and processes it) and creating a windows service that simply monitors the target queue (with a WAITFOR = -1 clause) and processes it?"

I guess I'm not sure how using the QUEUE_ACTIVATION Event Notification is really helping me.

Thanks,

Chris

If all you need is a single instance of your service and don't mind it running all the time, you could implement this as a Windows Service that does a WAITFOR with no timeout. But if you want multiple instances of your service to be dynamically activated depending on the rate of incoming messages and how quickly your service is able to consume them, the external activator becomes useful. The main purpose of the external activator is to make services scalable.

The external activator is also capable of monitoring multiple queues, each configured with its own service program. So if you had 10 services, you do not need to have 10 windows services running even when queues are idle. You will have a single external activator running which will dynamically launch the service programs as messages arrive.

Hope that helps,

Rushi

|||

Rushi,

After doing some more digging into the External Activator, I understand more clearly now. It seems that the scalability benefits are the real key for us. That and doing a WAITFOR with an indefinite timeout isn't so easy in a Windows Service.

Thanks,

Chris

|||The external activator does some of the hard things, like maintaining a recovery log so that if the process was to terminate and it came back up, it would recover state and not miss any notifications thus ensuring that queued messages do not get orphaned.

proper time to shrink tempdb size?

hi,
working on sql server 2000.
Can you shrink tempdb's log and data file size at any time
during the day on production servers?
Will this impact other user's jobs on the server?
many thanks.
JJPlease don't post independently in multiple newsgroups. You can add the
other newsgroups in the "Newsgroups" section in the header and it will show
up in all those simultaneously as will the answers. See my reply in the
other newsgroup.
Andrew J. Kelly
SQL Server MVP
"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
news:06b201c3a4da$e397ad60$a301280a@.phx.gbl...
> hi,
> working on sql server 2000.
> Can you shrink tempdb's log and data file size at any time
> during the day on production servers?
> Will this impact other user's jobs on the server?
> many thanks.
> JJ|||am I causing any problem this way? What's the difference
between the two ways?
Thanks.
JJ
>--Original Message--
>Please don't post independently in multiple newsgroups.
You can add the
>other newsgroups in the "Newsgroups" section in the
header and it will show
>up in all those simultaneously as will the answers. See
my reply in the
>other newsgroup.
>
>--
>Andrew J. Kelly
>SQL Server MVP
>
>"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in
message
>news:06b201c3a4da$e397ad60$a301280a@.phx.gbl...
>> hi,
>> working on sql server 2000.
>> Can you shrink tempdb's log and data file size at any
time
>> during the day on production servers?
>> Will this impact other user's jobs on the server?
>> many thanks.
>> JJ
>
>.
>|||Hi JJ
There could be problems, or at least wasted time and fewer people getting
answers. If you post INDEPENDENTLY in separate newsgroups, someone could
answer you one place, and someone else could read your question in a
different group, and not know that you had already been answered. The
threads are kept completely separate., A second person could spend time
researcching and responding to a question that had already been answered.
This is wasting time they could have used to help somebody else.
If you list all the newsgroups in the header in one post, then any answer
posted in one newsgroup will be visible to people reading your question in
any of the included newsgroups.
Does that make sense?
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
news:00f501c3a553$5bc5e3b0$a301280a@.phx.gbl...
> am I causing any problem this way? What's the difference
> between the two ways?
> Thanks.
> JJ
> >--Original Message--
> >
> >Please don't post independently in multiple newsgroups.
> You can add the
> >other newsgroups in the "Newsgroups" section in the
> header and it will show
> >up in all those simultaneously as will the answers. See
> my reply in the
> >other newsgroup.
> >
> >
> >
> >--
> >
> >Andrew J. Kelly
> >SQL Server MVP
> >
> >
> >"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:06b201c3a4da$e397ad60$a301280a@.phx.gbl...
> >> hi,
> >>
> >> working on sql server 2000.
> >>
> >> Can you shrink tempdb's log and data file size at any
> time
> >> during the day on production servers?
> >>
> >> Will this impact other user's jobs on the server?
> >>
> >> many thanks.
> >>
> >> JJ
> >
> >
> >.
> >|||Very well put Kalen... Thank you
--
Andrew J. Kelly
SQL Server MVP
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:%23BBKFdVpDHA.1020@.TK2MSFTNGP09.phx.gbl...
> Hi JJ
> There could be problems, or at least wasted time and fewer people getting
> answers. If you post INDEPENDENTLY in separate newsgroups, someone could
> answer you one place, and someone else could read your question in a
> different group, and not know that you had already been answered. The
> threads are kept completely separate., A second person could spend time
> researcching and responding to a question that had already been answered.
> This is wasting time they could have used to help somebody else.
> If you list all the newsgroups in the header in one post, then any answer
> posted in one newsgroup will be visible to people reading your question in
> any of the included newsgroups.
> Does that make sense?
> --
> HTH
> --
> Kalen Delaney
> SQL Server MVP
> www.SolidQualityLearning.com
>
> "JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
> news:00f501c3a553$5bc5e3b0$a301280a@.phx.gbl...
> > am I causing any problem this way? What's the difference
> > between the two ways?
> >
> > Thanks.
> >
> > JJ
> > >--Original Message--
> > >
> > >Please don't post independently in multiple newsgroups.
> > You can add the
> > >other newsgroups in the "Newsgroups" section in the
> > header and it will show
> > >up in all those simultaneously as will the answers. See
> > my reply in the
> > >other newsgroup.
> > >
> > >
> > >
> > >--
> > >
> > >Andrew J. Kelly
> > >SQL Server MVP
> > >
> > >
> > >"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in
> > message
> > >news:06b201c3a4da$e397ad60$a301280a@.phx.gbl...
> > >> hi,
> > >>
> > >> working on sql server 2000.
> > >>
> > >> Can you shrink tempdb's log and data file size at any
> > time
> > >> during the day on production servers?
> > >>
> > >> Will this impact other user's jobs on the server?
> > >>
> > >> many thanks.
> > >>
> > >> JJ
> > >
> > >
> > >.
> > >
>|||good to know. thank you for the pointers. never knew
about this until now. where can I go to find out more
tips like this? I think we should make this kind of rules
very visible for people so that there won't be any more
confusions like this.
JJ
>--Original Message--
>Very well put Kalen... Thank you
>--
>Andrew J. Kelly
>SQL Server MVP
>
>"Kalen Delaney" <replies@.public_newsgroups.com> wrote in
message
>news:%23BBKFdVpDHA.1020@.TK2MSFTNGP09.phx.gbl...
>> Hi JJ
>> There could be problems, or at least wasted time and
fewer people getting
>> answers. If you post INDEPENDENTLY in separate
newsgroups, someone could
>> answer you one place, and someone else could read your
question in a
>> different group, and not know that you had already been
answered. The
>> threads are kept completely separate., A second person
could spend time
>> researcching and responding to a question that had
already been answered.
>> This is wasting time they could have used to help
somebody else.
>> If you list all the newsgroups in the header in one
post, then any answer
>> posted in one newsgroup will be visible to people
reading your question in
>> any of the included newsgroups.
>> Does that make sense?
>> --
>> HTH
>> --
>> Kalen Delaney
>> SQL Server MVP
>> www.SolidQualityLearning.com
>>
>> "JJ Wang" <anonymous@.discussions.microsoft.com> wrote
in message
>> news:00f501c3a553$5bc5e3b0$a301280a@.phx.gbl...
>> > am I causing any problem this way? What's the
difference
>> > between the two ways?
>> >
>> > Thanks.
>> >
>> > JJ
>> > >--Original Message--
>> > >
>> > >Please don't post independently in multiple
newsgroups.
>> > You can add the
>> > >other newsgroups in the "Newsgroups" section in the
>> > header and it will show
>> > >up in all those simultaneously as will the answers.
See
>> > my reply in the
>> > >other newsgroup.
>> > >
>> > >
>> > >
>> > >--
>> > >
>> > >Andrew J. Kelly
>> > >SQL Server MVP
>> > >
>> > >
>> > >"JJ Wang" <anonymous@.discussions.microsoft.com>
wrote in
>> > message
>> > >news:06b201c3a4da$e397ad60$a301280a@.phx.gbl...
>> > >> hi,
>> > >>
>> > >> working on sql server 2000.
>> > >>
>> > >> Can you shrink tempdb's log and data file size at
any
>> > time
>> > >> during the day on production servers?
>> > >>
>> > >> Will this impact other user's jobs on the server?
>> > >>
>> > >> many thanks.
>> > >>
>> > >> JJ
>> > >
>> > >
>> > >.
>> > >
>>
>
>.
>|||today I followed your tip and posted one message with
multiple addresses to the group. One person answered me
in one group and also showed in the other, so this part
worked.
But when I answered back in one group, my answer didn't
get automatically posted in the other group. How come? I
sure hope this thing won't cause so much trouble for me.
JJ
>--Original Message--
>Very well put Kalen... Thank you
>--
>Andrew J. Kelly
>SQL Server MVP
>
>"Kalen Delaney" <replies@.public_newsgroups.com> wrote in
message
>news:%23BBKFdVpDHA.1020@.TK2MSFTNGP09.phx.gbl...
>> Hi JJ
>> There could be problems, or at least wasted time and
fewer people getting
>> answers. If you post INDEPENDENTLY in separate
newsgroups, someone could
>> answer you one place, and someone else could read your
question in a
>> different group, and not know that you had already been
answered. The
>> threads are kept completely separate., A second person
could spend time
>> researcching and responding to a question that had
already been answered.
>> This is wasting time they could have used to help
somebody else.
>> If you list all the newsgroups in the header in one
post, then any answer
>> posted in one newsgroup will be visible to people
reading your question in
>> any of the included newsgroups.
>> Does that make sense?
>> --
>> HTH
>> --
>> Kalen Delaney
>> SQL Server MVP
>> www.SolidQualityLearning.com
>>
>> "JJ Wang" <anonymous@.discussions.microsoft.com> wrote
in message
>> news:00f501c3a553$5bc5e3b0$a301280a@.phx.gbl...
>> > am I causing any problem this way? What's the
difference
>> > between the two ways?
>> >
>> > Thanks.
>> >
>> > JJ
>> > >--Original Message--
>> > >
>> > >Please don't post independently in multiple
newsgroups.
>> > You can add the
>> > >other newsgroups in the "Newsgroups" section in the
>> > header and it will show
>> > >up in all those simultaneously as will the answers.
See
>> > my reply in the
>> > >other newsgroup.
>> > >
>> > >
>> > >
>> > >--
>> > >
>> > >Andrew J. Kelly
>> > >SQL Server MVP
>> > >
>> > >
>> > >"JJ Wang" <anonymous@.discussions.microsoft.com>
wrote in
>> > message
>> > >news:06b201c3a4da$e397ad60$a301280a@.phx.gbl...
>> > >> hi,
>> > >>
>> > >> working on sql server 2000.
>> > >>
>> > >> Can you shrink tempdb's log and data file size at
any
>> > time
>> > >> during the day on production servers?
>> > >>
>> > >> Will this impact other user's jobs on the server?
>> > >>
>> > >> many thanks.
>> > >>
>> > >> JJ
>> > >
>> > >
>> > >.
>> > >
>>
>
>.
>|||If the original post was to multiple groups and you use the Reply to Group
feature it should post to all the groups.
--
Andrew J. Kelly
SQL Server MVP
"JJ Wang" <anonymous@.discussions.microsoft.com> wrote in message
news:067b01c3aa48$46ed2620$a101280a@.phx.gbl...
> today I followed your tip and posted one message with
> multiple addresses to the group. One person answered me
> in one group and also showed in the other, so this part
> worked.
> But when I answered back in one group, my answer didn't
> get automatically posted in the other group. How come? I
> sure hope this thing won't cause so much trouble for me.
> JJ
> >--Original Message--
> >Very well put Kalen... Thank you
> >
> >--
> >
> >Andrew J. Kelly
> >SQL Server MVP
> >
> >
> >"Kalen Delaney" <replies@.public_newsgroups.com> wrote in
> message
> >news:%23BBKFdVpDHA.1020@.TK2MSFTNGP09.phx.gbl...
> >> Hi JJ
> >>
> >> There could be problems, or at least wasted time and
> fewer people getting
> >> answers. If you post INDEPENDENTLY in separate
> newsgroups, someone could
> >> answer you one place, and someone else could read your
> question in a
> >> different group, and not know that you had already been
> answered. The
> >> threads are kept completely separate., A second person
> could spend time
> >> researcching and responding to a question that had
> already been answered.
> >> This is wasting time they could have used to help
> somebody else.
> >>
> >> If you list all the newsgroups in the header in one
> post, then any answer
> >> posted in one newsgroup will be visible to people
> reading your question in
> >> any of the included newsgroups.
> >>
> >> Does that make sense?
> >>
> >> --
> >> HTH
> >> --
> >> Kalen Delaney
> >> SQL Server MVP
> >> www.SolidQualityLearning.com
> >>
> >>
> >> "JJ Wang" <anonymous@.discussions.microsoft.com> wrote
> in message
> >> news:00f501c3a553$5bc5e3b0$a301280a@.phx.gbl...
> >> > am I causing any problem this way? What's the
> difference
> >> > between the two ways?
> >> >
> >> > Thanks.
> >> >
> >> > JJ
> >> > >--Original Message--
> >> > >
> >> > >Please don't post independently in multiple
> newsgroups.
> >> > You can add the
> >> > >other newsgroups in the "Newsgroups" section in the
> >> > header and it will show
> >> > >up in all those simultaneously as will the answers.
> See
> >> > my reply in the
> >> > >other newsgroup.
> >> > >
> >> > >
> >> > >
> >> > >--
> >> > >
> >> > >Andrew J. Kelly
> >> > >SQL Server MVP
> >> > >
> >> > >
> >> > >"JJ Wang" <anonymous@.discussions.microsoft.com>
> wrote in
> >> > message
> >> > >news:06b201c3a4da$e397ad60$a301280a@.phx.gbl...
> >> > >> hi,
> >> > >>
> >> > >> working on sql server 2000.
> >> > >>
> >> > >> Can you shrink tempdb's log and data file size at
> any
> >> > time
> >> > >> during the day on production servers?
> >> > >>
> >> > >> Will this impact other user's jobs on the server?
> >> > >>
> >> > >> many thanks.
> >> > >>
> >> > >> JJ
> >> > >
> >> > >
> >> > >.
> >> > >
> >>
> >>
> >
> >
> >.
> >

Proper table structure and SQL Server limits

Hello all,
I am migrating a Paradox application to SQL Server. My problem is that the
existing Paradox table structure is limited. Correcting it will mean a
re-write of the application (Delphi app). Although the record and column
limits are higher in SQL Server, it will eventually hit the wall. So I was
wondering if anyone could offer advise on how we might do this best...
The application is essentially an evaluation tool. It is very generic and
can evaluate anything from buying a digital camera or laptop, to purchasing
a house. All the attributes of whatever it is being measure (the
attributes) are defined as a new column.
Example: let's say you are evaluating laptops. The core table may look like
this:
Fields:
1) Identifier
2) Processor Speed
3) Processor Cache
4) Hard Disk Size
5) LAN connection
6) Cost
So in this table, there are 5 things being measure, 6 columns in total. A
record might look like this:
Field Data:
Identifier | Speed | Cache | HD Size | LAN | Cost ...
HP | 3ghz | 2mb | 60G | Wireless | $2000
So you can see that this structure will hit the wall eventually as more and
more criteria are added. With Paradox, the max number of columns is 255. In
SQL Server this is 1024. Of course there is also a maximum record size. For
SQL Server this is 8060 bytes.
What I'd prefer is a structure that has no limits on how big it can be. In
short, I need a new table structure that is long and skinny, vs very wide
(or fat):
Fields:
Identifier
Attribute
Value
So using the above example, the data might look like:
Field Data
Identifier | Attribute | Value
HP | Speed | 3ghz
HP | Cache | 2mb
HP | HD Size | 60G
HP | LAN | Wireless
HP | Cost | $2000
Obviously this structure is preferred because now I won't hit any column or
record limits, but it makes just about everything else in the application
more difficult. Fundamentally data validation becomes difficult
In the above example, how would one define this structure?
Identifier varchar(50)
Attribute varchar(50)
Value ' <-- here lies my problem!!!
In some cases "value" would be an integer, sometimes numeric, sometimes
text. So then I figured, well I could have a number of tables as above,
each for the various data types, integers, numbers, free form text, etc.
Example:
For Integer data
Identifier varchar(50)
Attribute varchar(50)
Value integer
For floating point data
Identifier varchar(50)
Attribute varchar(50)
Value numeric
For free-form data
Identifier varchar(50)
Attribute varchar(50)
Value varchar or ntext
So now I have taken what was in one table, and split it across 3 or more
tables. Of course, all this data would need to be "re-connected" in a grid
like fashion so it looks like just one row of data to the client again.
It all seems to be getting very messy - to simply overcome a column/row
size limitation. Surely there must be an eloquent way to do something like
this?
thanx very much for any input.
regards,
-randall sell"Randall Sell" <randall@.bytewise.nospam.com.au> wrote in message
news:lsjYc.12329$D7.11613@.news-server.bigpond.net.au...
> Hello all,
> I am migrating a Paradox application to SQL Server. My problem is that the
> existing Paradox table structure is limited. Correcting it will mean a
> re-write of the application (Delphi app). Although the record and column
> limits are higher in SQL Server, it will eventually hit the wall. So I was
> wondering if anyone could offer advise on how we might do this best...
>
. . .

> So now I have taken what was in one table, and split it across 3 or more
> tables. Of course, all this data would need to be "re-connected" in a grid
> like fashion so it looks like just one row of data to the client again.
> It all seems to be getting very messy - to simply overcome a column/row
> size limitation. Surely there must be an eloquent way to do something like
> this?
>
You have pretty much worked through he issues here. And you're right: the
free-form attribute storage is a pain to manage, has no data integrity and
performs terribly. I'll just add that it's also not what relational
databases are _for_. An RDBMS is designed to model data using relations. A
relation is a tuple of related values, like
( HP, 3ghz, 2mb, 60G, Wireless, $2000 )
So the original design is the correct one. Mainly for performance reasons,
SqlServer puts a limit on the size of rows (in bytes and in number of
columns). If you really run out of room, you can always just create a
second table, and a third, etc which have a one-to-one relationship with
your original table.
David|||Now why didn't I think of that? That is the sort of input I was looking
for. It would also have some problems, such as creating dynamic queries and
not knowing which table contains a field, but the meta data should sort
that out, so it should be manageable.
thanx
-randall
David Browne wrote:
> So the original design is the correct one. Mainly for performance reasons
,
> SqlServer puts a limit on the size of rows (in bytes and in number of
> columns). If you really run out of room, you can always just create a
> second table, and a third, etc which have a one-to-one relationship with
> your original table.
> David
>

Proper table structure and SQL Server limits

Hello all,
I am migrating a Paradox application to SQL Server. My problem is that the
existing Paradox table structure is limited. Correcting it will mean a
re-write of the application (Delphi app). Although the record and column
limits are higher in SQL Server, it will eventually hit the wall. So I was
wondering if anyone could offer advise on how we might do this best...
The application is essentially an evaluation tool. It is very generic and
can evaluate anything from buying a digital camera or laptop, to purchasing
a house. All the attributes of whatever it is being measure (the
attributes) are defined as a new column.
Example: let's say you are evaluating laptops. The core table may look like
this:
Fields:
1) Identifier
2) Processor Speed
3) Processor Cache
4) Hard Disk Size
5) LAN connection
6) Cost
So in this table, there are 5 things being measure, 6 columns in total. A
record might look like this:
Field Data:
Identifier | Speed | Cache | HD Size | LAN | Cost ...
HP | 3ghz | 2mb | 60G | Wireless | $2000
So you can see that this structure will hit the wall eventually as more and
more criteria are added. With Paradox, the max number of columns is 255. In
SQL Server this is 1024. Of course there is also a maximum record size. For
SQL Server this is 8060 bytes.
What I'd prefer is a structure that has no limits on how big it can be. In
short, I need a new table structure that is long and skinny, vs very wide
(or fat):
Fields:
Identifier
Attribute
Value
So using the above example, the data might look like:
Field Data
Identifier | Attribute | Value
HP | Speed | 3ghz
HP | Cache | 2mb
HP | HD Size | 60G
HP | LAN | Wireless
HP | Cost | $2000
Obviously this structure is preferred because now I won't hit any column or
record limits, but it makes just about everything else in the application
more difficult. Fundamentally data validation becomes difficult
In the above example, how would one define this structure?
Identifier varchar(50)
Attribute varchar(50)
Value ' <-- here lies my problem!!!
In some cases "value" would be an integer, sometimes numeric, sometimes
text. So then I figured, well I could have a number of tables as above,
each for the various data types, integers, numbers, free form text, etc.
Example:
For Integer data
Identifier varchar(50)
Attribute varchar(50)
Value integer
For floating point data
Identifier varchar(50)
Attribute varchar(50)
Value numeric
For free-form data
Identifier varchar(50)
Attribute varchar(50)
Value varchar or ntext
So now I have taken what was in one table, and split it across 3 or more
tables. Of course, all this data would need to be "re-connected" in a grid
like fashion so it looks like just one row of data to the client again.
It all seems to be getting very messy - to simply overcome a column/row
size limitation. Surely there must be an eloquent way to do something like
this?
thanx very much for any input.
regards,
-randall sell"Randall Sell" <randall@.bytewise.nospam.com.au> wrote in message
news:lsjYc.12329$D7.11613@.news-server.bigpond.net.au...
> Hello all,
> I am migrating a Paradox application to SQL Server. My problem is that the
> existing Paradox table structure is limited. Correcting it will mean a
> re-write of the application (Delphi app). Although the record and column
> limits are higher in SQL Server, it will eventually hit the wall. So I was
> wondering if anyone could offer advise on how we might do this best...
>
. . .
> So now I have taken what was in one table, and split it across 3 or more
> tables. Of course, all this data would need to be "re-connected" in a grid
> like fashion so it looks like just one row of data to the client again.
> It all seems to be getting very messy - to simply overcome a column/row
> size limitation. Surely there must be an eloquent way to do something like
> this?
>
You have pretty much worked through he issues here. And you're right: the
free-form attribute storage is a pain to manage, has no data integrity and
performs terribly. I'll just add that it's also not what relational
databases are _for_. An RDBMS is designed to model data using relations. A
relation is a tuple of related values, like
( HP, 3ghz, 2mb, 60G, Wireless, $2000 )
So the original design is the correct one. Mainly for performance reasons,
SqlServer puts a limit on the size of rows (in bytes and in number of
columns). If you really run out of room, you can always just create a
second table, and a third, etc which have a one-to-one relationship with
your original table.
David|||Now why didn't I think of that? That is the sort of input I was looking
for. It would also have some problems, such as creating dynamic queries and
not knowing which table contains a field, but the meta data should sort
that out, so it should be manageable.
thanx
-randall
David Browne wrote:
> So the original design is the correct one. Mainly for performance reasons,
> SqlServer puts a limit on the size of rows (in bytes and in number of
> columns). If you really run out of room, you can always just create a
> second table, and a third, etc which have a one-to-one relationship with
> your original table.
> David
>sql

Proper table structure and SQL Server limits

Hello all,
I am migrating a Paradox application to SQL Server. My problem is that the
existing Paradox table structure is limited. Correcting it will mean a
re-write of the application (Delphi app). Although the record and column
limits are higher in SQL Server, it will eventually hit the wall. So I was
wondering if anyone could offer advise on how we might do this best...
The application is essentially an evaluation tool. It is very generic and
can evaluate anything from buying a digital camera or laptop, to purchasing
a house. All the attributes of whatever it is being measure (the
attributes) are defined as a new column.
Example: let's say you are evaluating laptops. The core table may look like
this:
Fields:
1) Identifier
2) Processor Speed
3) Processor Cache
4) Hard Disk Size
5) LAN connection
6) Cost
So in this table, there are 5 things being measure, 6 columns in total. A
record might look like this:
Field Data:
Identifier | Speed | Cache | HD Size | LAN | Cost ...
HP | 3ghz | 2mb | 60G | Wireless | $2000
So you can see that this structure will hit the wall eventually as more and
more criteria are added. With Paradox, the max number of columns is 255. In
SQL Server this is 1024. Of course there is also a maximum record size. For
SQL Server this is 8060 bytes.
What I'd prefer is a structure that has no limits on how big it can be. In
short, I need a new table structure that is long and skinny, vs very wide
(or fat):
Fields:
Identifier
Attribute
Value
So using the above example, the data might look like:
Field Data
Identifier | Attribute | Value
HP | Speed | 3ghz
HP | Cache | 2mb
HP | HD Size | 60G
HP | LAN | Wireless
HP | Cost | $2000
Obviously this structure is preferred because now I won't hit any column or
record limits, but it makes just about everything else in the application
more difficult. Fundamentally data validation becomes difficult
In the above example, how would one define this structure?
Identifier varchar(50)
Attribute varchar(50)
Value ? <-- here lies my problem!!!
In some cases "value" would be an integer, sometimes numeric, sometimes
text. So then I figured, well I could have a number of tables as above,
each for the various data types, integers, numbers, free form text, etc.
Example:
For Integer data
Identifier varchar(50)
Attribute varchar(50)
Value integer
For floating point data
Identifier varchar(50)
Attribute varchar(50)
Value numeric
For free-form data
Identifier varchar(50)
Attribute varchar(50)
Value varchar or ntext
So now I have taken what was in one table, and split it across 3 or more
tables. Of course, all this data would need to be "re-connected" in a grid
like fashion so it looks like just one row of data to the client again.
It all seems to be getting very messy - to simply overcome a column/row
size limitation. Surely there must be an eloquent way to do something like
this?
thanx very much for any input.
regards,
-randall sell
"Randall Sell" <randall@.bytewise.nospam.com.au> wrote in message
news:lsjYc.12329$D7.11613@.news-server.bigpond.net.au...
> Hello all,
> I am migrating a Paradox application to SQL Server. My problem is that the
> existing Paradox table structure is limited. Correcting it will mean a
> re-write of the application (Delphi app). Although the record and column
> limits are higher in SQL Server, it will eventually hit the wall. So I was
> wondering if anyone could offer advise on how we might do this best...
>
.. . .

> So now I have taken what was in one table, and split it across 3 or more
> tables. Of course, all this data would need to be "re-connected" in a grid
> like fashion so it looks like just one row of data to the client again.
> It all seems to be getting very messy - to simply overcome a column/row
> size limitation. Surely there must be an eloquent way to do something like
> this?
>
You have pretty much worked through he issues here. And you're right: the
free-form attribute storage is a pain to manage, has no data integrity and
performs terribly. I'll just add that it's also not what relational
databases are _for_. An RDBMS is designed to model data using relations. A
relation is a tuple of related values, like
( HP, 3ghz, 2mb, 60G, Wireless, $2000 )
So the original design is the correct one. Mainly for performance reasons,
SqlServer puts a limit on the size of rows (in bytes and in number of
columns). If you really run out of room, you can always just create a
second table, and a third, etc which have a one-to-one relationship with
your original table.
David
|||Now why didn't I think of that? That is the sort of input I was looking
for. It would also have some problems, such as creating dynamic queries and
not knowing which table contains a field, but the meta data should sort
that out, so it should be manageable.
thanx
-randall
David Browne wrote:
> So the original design is the correct one. Mainly for performance reasons,
> SqlServer puts a limit on the size of rows (in bytes and in number of
> columns). If you really run out of room, you can always just create a
> second table, and a third, etc which have a one-to-one relationship with
> your original table.
> David
>

Proper Syntax of CASE() ion a cell in RS?

Hello All;
I was wondering if there is a way to make decisions on a particular cell in a
report (Tabular of Matrix) where the "CASE" effect can be achieved. I use IIF
(SOMEHTING >0,"RED","Green") all over, but I wonder if the decision making
can be expanded on Cell's content so as to get the Effect of CASE ot IF
ElseIF Else as follows:
If (SOMTHING) Then (DoSomething)
(ElseIF DOSomethingElse1)
(ElseIF DoSomethingElse2)
Else
(DoOtherwise)
Thank you.
--
Message posted via http://www.sqlmonster.comThe best way is to write some code and call it.
In Report properties go to the code page and enter a VisualBasic .Net
function eg:
Function SetColour(ByVal N As Double) As String
Select N
Case 0
Return "White"
Case >0
Return "Blue"
Case Else
Return "Red"
End Select
End Function
then call the function in your expression to set the colour of a cell eg:
=Code.SetColour( Fields!CurrencyAmount.Value-Sum(Fields!AmountExpensed.Value))
"James Woo via SQLMonster.com" wrote:
> Hello All;
> I was wondering if there is a way to make decisions on a particular cell in a
> report (Tabular of Matrix) where the "CASE" effect can be achieved. I use IIF
> (SOMEHTING >0,"RED","Green") all over, but I wonder if the decision making
> can be expanded on Cell's content so as to get the Effect of CASE ot IF
> ElseIF Else as follows:
> If (SOMTHING) Then (DoSomething)
> (ElseIF DOSomethingElse1)
> (ElseIF DoSomethingElse2)
> Else
> (DoOtherwise)
> Thank you.
> --
> Message posted via http://www.sqlmonster.com
>|||Mary .. Thank you :), very nice code.
--
Message posted via http://www.sqlmonster.com|||Based on the information below I have been able to create code, however I
need to test for a value between 2 numbers..ex
Case < 366
Return "1 yr or less"
Case >0 and <731
Return "1-2 years"
I am running into an issue with line 3. Is it possible? Am I using the
wrong syntax? If this is not the best approach what would that be?
Thank you for any guidance.
"Mary Bray [SQL Server MVP]" wrote:
> The best way is to write some code and call it.
> In Report properties go to the code page and enter a VisualBasic .Net
> function eg:
> Function SetColour(ByVal N As Double) As String
> Select N
> Case 0
> Return "White"
> Case >0
> Return "Blue"
> Case Else
> Return "Red"
> End Select
> End Function
> then call the function in your expression to set the colour of a cell eg:
> =Code.SetColour( Fields!CurrencyAmount.Value-Sum(Fields!AmountExpensed.Value))
> "James Woo via SQLMonster.com" wrote:
> > Hello All;
> >
> > I was wondering if there is a way to make decisions on a particular cell in a
> > report (Tabular of Matrix) where the "CASE" effect can be achieved. I use IIF
> > (SOMEHTING >0,"RED","Green") all over, but I wonder if the decision making
> > can be expanded on Cell's content so as to get the Effect of CASE ot IF
> > ElseIF Else as follows:
> > If (SOMTHING) Then (DoSomething)
> > (ElseIF DOSomethingElse1)
> > (ElseIF DoSomethingElse2)
> > Else
> > (DoOtherwise)
> > Thank you.
> >
> > --
> > Message posted via http://www.sqlmonster.com
> >|||I was able to find some information, this may helps others...
Case < 366
Return "1 yr or less"
Case 0 To 731
Return "1-2 years"
"DigitalVixen" wrote:
> Based on the information below I have been able to create code, however I
> need to test for a value between 2 numbers..ex
> Case < 366
> Return "1 yr or less"
> Case >0 and <731
> Return "1-2 years"
> I am running into an issue with line 3. Is it possible? Am I using the
> wrong syntax? If this is not the best approach what would that be?
> Thank you for any guidance.
> "Mary Bray [SQL Server MVP]" wrote:
> > The best way is to write some code and call it.
> > In Report properties go to the code page and enter a VisualBasic .Net
> > function eg:
> > Function SetColour(ByVal N As Double) As String
> > Select N
> > Case 0
> > Return "White"
> > Case >0
> > Return "Blue"
> > Case Else
> > Return "Red"
> > End Select
> > End Function
> >
> > then call the function in your expression to set the colour of a cell eg:
> >
> > =Code.SetColour( Fields!CurrencyAmount.Value-Sum(Fields!AmountExpensed.Value))
> >
> > "James Woo via SQLMonster.com" wrote:
> >
> > > Hello All;
> > >
> > > I was wondering if there is a way to make decisions on a particular cell in a
> > > report (Tabular of Matrix) where the "CASE" effect can be achieved. I use IIF
> > > (SOMEHTING >0,"RED","Green") all over, but I wonder if the decision making
> > > can be expanded on Cell's content so as to get the Effect of CASE ot IF
> > > ElseIF Else as follows:
> > > If (SOMTHING) Then (DoSomething)
> > > (ElseIF DOSomethingElse1)
> > > (ElseIF DoSomethingElse2)
> > > Else
> > > (DoOtherwise)
> > > Thank you.
> > >
> > > --
> > > Message posted via http://www.sqlmonster.com
> > >

Proper syntax for bulk insert?

Hi,

I'm working in vb.net and want to use a stored procedure to insert all employees from one db into my db. I can insert one by one, but I would like to get them all in without looping.

How would I do this? I've tried bulk insert, but I keep getting syntax errors; I've read the books online, but don't quite understand what they mean. I don't want to use DTS, should I?

Here is what I'm doing so far:

CREATE Procedure Insert_From_Personnel
@.emp_num char(10),
@.Frst_Name char(10),
@.Last_Name char(10),
@.DivisionID char (4)

as

INSERT into individual (IndividualID,FirstName,LastName,DivisionID)

VALUES (@.emp_num,@.Frst_Name,@.Last_Name,@.DivisionID)
GO

Thanks for any help,SELECT * INTO myDB..Table FROM oneDB..Table|||Thanks Brett,

Now it's giving me an error that says 'object Individual is already in the database.'

Have I placed the select * in the right place?

CREATE Procedure Insert_From_Personnel
@.emp_num char(10),
@.Frst_Name char(10),
@.Last_Name char(10),
@.DivisionID char (4)

as

select * into individual from FROMGDPersonnelByDivision

INSERT into individual (IndividualID,FirstName,LastName,DivisionID)

VALUES (@.emp_num,@.Frst_Name,@.Last_Name,@.DivisionID)
GO

Thanks,|||insert into db1..Individual (fields)
select fields
from db2..Individual

This will bring over all of the records, so be careful about primary/unique key constraints. Sounds like you may be doing a refresh of data for a testing database?|||Itmay take forever though. If 'select into' is enabled on db1 I'd use Brett's approach by dropping Individual from db1 and using select * into... from ...|||insert into db1..Individual (fields)
select fields
from db2..Individual

This will bring over all of the records, so be careful about primary/unique key constraints. Sounds like you may be doing a refresh of data for a testing database?

fields...oye...|||OK, OK. I am being lazy. I admit it. ;-)

Still, it is slightly better than

insert into table
select *
from other_table|||Thanks guys, I DO need all the help I can get...

MCrowley, I am creating an appliction for two users. Once a week, or whenever, I want the user to be able to import people and info from the Personnel db into the Individuals table. The field names are different.

At this point, I don't mind slow, I just want to see it work. So now I've got:

CREATE Procedure Insert_From_Personnel

as

INSERT into individual (IndividualID,FirstName,LastName,DivisionID)
select emp_num,frst_name,last_name,[division id]
from FROMGDPersonnelByDivision

GO

I wiped out everything to start from scratch. I ran the SP and got the 'string or binary data would be truncated' error. Ran it again and got the 'violation of PK_Individual' error. There isn't any data in the table yet, how can it be violated?

Just to see if I've got it right, I took the PK off and it worked! It was pretty speedy, too. I'll try to write something on the vb.net side to Update if it sees the same emp_num and Insert if that emp_num doesn't exist.

One last thing... how can I say if it DOESN'T exist INSERT in the SP?

Thanks for your help!|||if not exists (select...)|||I'm getting closer, I hope. I've tried the if exists all over the place and weeded it down to only one 'incorrect syntax' near from FROMGDPersonnelByDivision

What the heck am I missing?!

CREATE Procedure Insert_From_Personnel
as
if not exists (select emp_num,frst_name,last_name,[division id])

INSERT into individual (IndividualID,FirstName,LastName,DivisionID)

from FROMGDPersonnelByDivision
GO

Can I have one more hint, please?|||Yeah, I agree, the combination is finite and you're close ;)

CREATE Procedure Insert_From_Personnel
as
if not exists (select 1 from FROMGDPersonnelByDivision where <something> = <something>) INSERT into individual (IndividualID,FirstName,LastName,DivisionID)
else
print 'Record already exists'
return (0)
GO|||rdjabarov,

Help me out here. Why isn't this working?

When I use your example (simplified):
CREATE Procedure Insert_From_Personnel

as

if not exists (select emp_num,frst_name, last_name, [division id] from FROMGDPersonnelByDivision where emp_num = emp_num)
INSERT into individual (IndividualID,FirstName,LastName,DivisionID)

GO

It gives me the 'incorrect syntax near ')' after the last DivisionID, as if it needs something more.

After looking around on the web and in my Murach book, I tried putting values back in and using 'default values'. But then it has problems with the 'as'. As if it does not want VALUES using the 'if not exists'. What does it need? I'm not finding much info about combining 'if not' with 'insert into'.

Thanks for any help!|||The INSERT INTO requires either a VALUES clause or a SELECT statement to provide the data that you want inserted.

-PatP|||Hmmmm... OK,

The select is there. It makes sense in english;

if this doesn't exist: (the data from these columns, from THAT table) then INSERT it into THIS table

>> (select emp_num,frst_name, last_name, [division id] from >>FROMGDPersonnelByDivision where emp_num = emp_num)

Will I have better luck using 'WHERE NOT EXISTS'? Is there a difference?

Thanks,|||How about:INSERT into individual (
IndividualID, FirstName, LastName
, DivisionID
) SELECT
emp_num, frst_name, last_name
, [division id]
FROM FROMGDPersonnelByDivision
WHERE NOT EXSISTS (SELECT *
FROM individual AS b
WHERE b.InidividualID = FROMGDPersonnelByDivision.emp_num)-PatP|||Pat! Pat! It worked!

I was just trying to manipulate the code you gave for the 'Create Trigger?' post. I knew that the a.xxx and b.xxx sounded like where I should go. I didn't know I could just use a 'b'.

Thank you SO much! I'll be using this all over the place at work, so it's very important I get this concept down.|||Well, I am glad someone has a better eye sight than me ;)

Proper Sorting of Months In DropdownList

I'm having an issue getting the data how I want it from SQL to then populate my dropdownlist.

I have a table called SALES_BUDGR_TBL that contains alot of columns but the ones I'm focusing on are SRCURM (Month) and SRACYR (Year). What I need to do is populate a dropdownlist and show the current month first and then work backwards. The data in the dabase goes back 14 months. I created a reference table called MonthOrder that has 3 columns, MonthID, MonthName and MonthAbrv. I did this so I have a way of saying which month belongs where when sorted.

Here is the select statement I currently have. I'm joining the tables and then I want to Order by the MonthID, but I would also like it to show the 2006 records first, then goto 2005, starting with December and going down of course.

Is there anyway to do this? My Select and Results are below...

SELECT DISTINCT SB.SRCURM, SB.SRACYR, MO.MonthID, MO.MonthName FROM SALES_BUDGR_TBL SB
INNER JOIN MonthOrder MO ON SB.SRCURM = MO.MonthAbrv
ORDER BY MO.MonthID DESC

DEC 2005 12 December
NOV 2005 11 November
OCT 2005 10 October
SEP 2005 09 September
AUG 2005 08 August
JUL 2005 07 July
JUN 2005 06 June
MAY 2005 05 May
APR 2005 04 April
APR 2006 04 April
MAR 2006 03 March
FEB 2005 02 Febuary
FEB 2006 02 Febuary
JAN 2006 01 January

If I say only get 2006 records it works but I need a better way to do this.

Please try to modify your ORDER clause to:

ORDER BY SB.SRACYR DESC, MO.MonthID DESC

|||

SELECT DISTINCT SB.SRACYR AS Year,DATEPART(month,SB.SRCURM+' 01, 2006') AS Month,CAST(SB.SRCURM+' 01, '+SB.SRACYR) AS MyDate FROM SALES_BUDGR_TBL SB
ORDER BY SB.SRACYR DESC,DATEPART(month,SB.SRCURM+' 01, 2006') DESC

|||Thanks, I got it working.

proper shutdown order for MSCS SQL cluster?

Hi,
We're having a SAN outage & I've noticed some **flakiness with regard to a
'clean' shutdown of our SQL 2000(active/active) & 2005(active/passive)
clusters.
**In the past when we've disconnected storage and had to cold boot all the
cluster nodes, we've had trouble starting the cluster back up. ( network
name not found in the cluster resource group and/or cluster services
wouldn't start)
Is there a recommended order to shut down & restart cluster resource groups
(including SQL+DTC) when system maintenanence need to occur?
Thanks,
Mike Bonvie
Shutdown:
Take the SQL resources offline and set the startup type to DISABLED on all
nodes
Stop the Cluster Service on all nodes and set the startup type to disabled.
Perform hardwarework as necessary.
Only boot one node at a time. If all nodes are down, us a staggered startup
sequence.
Enable and start cluster services on each node. Test moving the cluster
group.
Set SQL Service startup type to MANUAL.
Using the cluster admin tool, bring the diskm IP address, and network name
resources online. Test moving them across nodes.
Bring the SQL Services online using the cluster tool. Test moving groups.
Geoff N. Hiten
Senior Database Administrator
Microsoft SQL Server MVP
"Mike Bonvie" <m@.d.net> wrote in message
news:e7WcCzMYHHA.1388@.TK2MSFTNGP05.phx.gbl...
> Hi,
> We're having a SAN outage & I've noticed some **flakiness with regard to a
> 'clean' shutdown of our SQL 2000(active/active) & 2005(active/passive)
> clusters.
> **In the past when we've disconnected storage and had to cold boot all the
> cluster nodes, we've had trouble starting the cluster back up. ( network
> name not found in the cluster resource group and/or cluster services
> wouldn't start)
> Is there a recommended order to shut down & restart cluster resource
> groups (including SQL+DTC) when system maintenanence need to occur?
> Thanks,
> Mike Bonvie
|||Thank You Geoff,
Great information. Is this based on Microsoft documentation, or a combo of
experience/documentation?
If there's a KB or other resource, where can I get it?
Thanks again,
Mike Bonvie
"Geoff N. Hiten" <SQLCraftsman@.gmail.com> wrote in message
news:u$vRT9MYHHA.4440@.TK2MSFTNGP03.phx.gbl...
> Shutdown:
> Take the SQL resources offline and set the startup type to DISABLED on all
> nodes
> Stop the Cluster Service on all nodes and set the startup type to
> disabled.
> Perform hardwarework as necessary.
> Only boot one node at a time. If all nodes are down, us a staggered
> startup sequence.
> Enable and start cluster services on each node. Test moving the cluster
> group.
> Set SQL Service startup type to MANUAL.
> Using the cluster admin tool, bring the diskm IP address, and network name
> resources online. Test moving them across nodes.
> Bring the SQL Services online using the cluster tool. Test moving groups.
>
> --
> Geoff N. Hiten
> Senior Database Administrator
> Microsoft SQL Server MVP
>
>
> "Mike Bonvie" <m@.d.net> wrote in message
> news:e7WcCzMYHHA.1388@.TK2MSFTNGP05.phx.gbl...
>
|||This is a mix of best practices guidelines and experience. The staggered
startup is documented somewhere, but the other steps are stuff I have worked
out over the years. The DISABLED service ettings just makes sure the
resource won't attempt to come online accidentally.
Geoff N. Hiten
Senior Database Administrator
Microsoft SQL Server MVP
"Mike Bonvie" <m@.d.net> wrote in message
news:Oqu9AHNYHHA.4552@.TK2MSFTNGP05.phx.gbl...
> Thank You Geoff,
> Great information. Is this based on Microsoft documentation, or a combo of
> experience/documentation?
> If there's a KB or other resource, where can I get it?
> Thanks again,
> Mike Bonvie
>
> "Geoff N. Hiten" <SQLCraftsman@.gmail.com> wrote in message
> news:u$vRT9MYHHA.4440@.TK2MSFTNGP03.phx.gbl...
>
sql

Proper Procedure to change servername of replicated environemnts?

Hi There

Firslty this is a question concerning sql server 2000 hope this is not just a 2005 forum?

I need to change the servername of a few of our sql 2000 database servers.
I know the procedure to change the name and reconfigure sql with the new servername.
What i am concerned about is that these databases are being replicated via a remote distributor.
Obviously the subscriptions stipulate the servernames , i am concerned about what will happen to replication when the server name is changed i have a feeling replication will fall over.
Does anyone have a good link or white paper on proper procedure to change server names on replicated sql server databases.
I will also need to change the server name of the remote distributor.

This whole procedure could be tricky and i am not 100% sure about the proper procedure and i cannot find anything useful in BOL.
I am hoping all i have to do is stop certain replication agents , change the subscription info and start them again but i am really not sure.

Any help would be appreciated.

Thanx

Sean,

Server rename does not support replication. You can script replication from Enterprise Manager or SQL Server Management Studio, drop it, rename the server, and then rerun the script after modifying it with search and replace to use the new name.

-Matt|||Hi Matt

I have found a BOL reference basically you do have to disable replication, so subscriptions will have to be reinitialzed afterwards.
ALso i have foubd that when you script replication the sql it produces in littered with syntactical errors.

But i have made a plan.

Thanx for the advise.