Showing posts with label back. Show all posts
Showing posts with label back. Show all posts

Wednesday, March 28, 2012

Normalize your database: NOT OPTIONAL!

I've been away for a while but now that I'm back one if the first things I noticed is how many of the problems on this forum could have been easily avoided by simply normalizing the database in question.

For those of you without formal SQL training, know this: Youhave to normalize your database. This is part of the process of database development. You can not just whack together a few tables in whatever way is the easiest for the problem at hand, because eventually your requirements will expand and then you need your data to be flexible.

Seriously, in the last 3 weeks I've seen many many questions where it is obvious that the problem is a flawed DB design, but all the so-called SQL gurus here will just answer the question without addressing the fact that the problem lies much deeper.

Here's a link I found on Google:
http://www.cse.unsw.edu.au/~cs3710/PMmaterials/Tutorials/normalise.htmGood point, but a qualifier :

sometimes de-normalizing is required or at least advisable from a performance point of view, though your point holds in thevast majority of cases. Your statement holds for virtually anoyone asking questions in this forum though.

j|||Yes, although your starting point is always a normalized DB. If you then realize you need to de-normalize for performance, then so be it. Never the other way around though.|||::sometimes de-normalizing is required or at least advisable from a performance point of
::view

Yes, and professionals call this thn a datawarehouse, where completly different rules apply.

Interesting nough I have never seen questions about data warehousing here, evryone is just dealing with transactional (OLTP) databases.|||It's a given to normalize your database to a certain degree. It's faster to select on an integer or bit based where clause than it would a float or varchar.

However, Atrax is correct, you can't really say it's the best choice since it's not ALWAYS the case. Especially when you have a normalized table of more than 15 tables, and some of those tables only hold 3-5 records of two fields, one being an identity.

Let's take for instance states. States don't change, and a char(2) is all you really need to store that data. Why would you have another field that takes up 4bytes to store an identity field FK of the normalized table holding "states"?

So Pierre, and valiant as your intentions were, it's still considered at the disgretion of the developer/dba to maintain how these tables will be designed for optimal storage as well as retrieval.|||I'm not saying take your DB to 5NF or DKNF, just 3NF is fine. What you're illustrating is still a 3NF normalized DB, and thus is still OK for just about any purpose out there. I'm not saying your DB should always be 100% normalized. I'm just pointing out that many developers simply skip that altogether.

All I'm saying is no normalization is BAD. E.g.

UserID int, Languages varchar(100)
(1, '1, 2, 5, 7')

I agree with your example, I personally use non-integer fields as PKs often. And if updates are possible but unlikely, you can even use cascade updates. But the DB is still normalized and should still have FKs etc.|||The problem is, many of the people on this forum don't even know what normalization is...

Heck, in the professional world there are a lot of people that don't understand this.

I am on a project where a programmer needed to know what what type of item something was.

Instead of adding a table of the types, and a foreign key to his original table, he added a column for each of the types to the table, and had a "Y" in the correct one and "N" in all the incorrect ones...|||Probably someone with COBOL experience...|||I think that Pierre's original point, and his intention, are solid. Even though there are certainly exceptions, many people who post here would benefit significantly from learning the basics of normalization, and the link looks like a solid tutorial. Learn the rules, then learn how (and when) to break the rules.

Friday, March 23, 2012

Noob Question: How to get Reporting Services

I'm evaluating using SQL for running the back end of a medium sized business. We're looking at using reporting services to cull information from several dbs, some of which are owned by partner companies who may or may not be running SQL 2005.

What I'm trying to figure out is; can I just go online and download reporting services somewhere for pre 2005 sql installations? Does it cost anything? Browsing the MS download pages has given me no results thus far.

Thanks much

I found my own answer - I can get the functionality I need through the redistributable here: http://www.microsoft.com/downloads/details.aspx?familyid=8A166CAC-758D-45C8-B637-DD7726E61367&displaylang=en#Overview

Thanks

Wednesday, March 21, 2012

Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.

Hi all,

Sometimes when I do "alter database ABCD set partner failover" I get the following message: Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.

In 99 percent of the cases after such message the first attempt to use an open connection would also raise an error such as "Exception: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)"

After the first error all subsequent queries would run perfectly.

What am I missing?

Avi

The first message indicates that there were users found in the principal when you issued the failover. These users have to be killed and their transactions rolled back.

The second exception message tends to indicate that the connection getting the error was one of the users found in that database and they were killed.

|||

Thanks for the reply!

Could you please elaborate some more why the connection sometimes get killed and the action rolled back. Does not mirroring suppose to move the connection to the active database without killing it?

Thanks,

Avi

|||No, that is not how it works. It can reconnect to the new mirror, but the existing connection will get killed and its transaction rolled back.|||Standard database projection requires that if a connection is killed prior to the transaction being completed that the transaction must be rolled back. By initiating a failover all connections are severed and must therefor be rolled back.

Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.

Hi all,

Sometimes when I do "alter database ABCD set partner failover" I get the following message: Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.

In 99 percent of the cases after such message the first attempt to use an open connection would also raise an error such as "Exception: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)"

After the first error all subsequent queries would run perfectly.

What am I missing?

Avi

The first message indicates that there were users found in the principal when you issued the failover. These users have to be killed and their transactions rolled back.

The second exception message tends to indicate that the connection getting the error was one of the users found in that database and they were killed.

|||

Thanks for the reply!

Could you please elaborate some more why the connection sometimes get killed and the action rolled back. Does not mirroring suppose to move the connection to the active database without killing it?

Thanks,

Avi

|||No, that is not how it works. It can reconnect to the new mirror, but the existing connection will get killed and its transaction rolled back.|||Standard database projection requires that if a connection is killed prior to the transaction being completed that the transaction must be rolled back. By initiating a failover all connections are severed and must therefor be rolled back.

Saturday, February 25, 2012

No way to pass identity back to SqlDataSource?

Is there no way to pass identity info back through SqlDataSource? You can only do that with ADO.NET code?

In other words, if I want to run a complex INSERT statement to a table that uses Identity, I can't take that key value back through something like SCOPE_IDENTITY() and use it?

I know how to do this with ADO code, but I can't figure out how to do it purely with SqlDataSource. I was hoping to do this without having to write a new Insert statement -- just using the one that's already in the SqlDataSource control. But there doesn't seem to be any facility for Identity in there. I tried embedding a separate select statement after the insert statement and a semi-colon, but that didn't seem to do anything.

Thanks!

Check out my reply on this post:http://forums.asp.net/thread/1284900.aspx

This is how I successfully got an output parameter back from my stored procedure using the sqldatasource, for instance the Identity after I inserted a record.

Hope this helps.

|||

I appreciate the reply, but I just don't see how that can work without a stored procedure. The problem is that I can't sneak the SCOPE_IDENTITY event into the Insert transaction through SqlDataSource. I can declare it separately in ADO code during the same (SqlDataSource-based) Insertion loop, but SQL Server sees that as a separate transaction and returns a DBNULL -- the scope is different, so no identity gets returned.

I can define the entire Insert event in ADO code, but then that would remove the function from the SqlDataSource, which was a design goal. Or I can dump the whole thing in a Stored Procedure, but that would also violate a design goal. (I realize this is a fairly academic exercise, but I've become curious at this point and really want to find the correct answer.)

In short, I'm just a-boggle that there's no way to return Identity entirely within the confines of SqlDataSource. It seems a fairly obvious thing to include. They obviously want us using this thing for Insertions, and it's a fairly obvious thing to do when inserting, but it does not appear to be allowed.

Surely I must just be missing something.

|||

Does anybody have any further thoughts on this? It doesn't appear there's any way to pass Identity back through SqlDataSource without moving the Insert statement out to ADO code or using a Stored Procedure. SqlDataSource doesn't appear to have any facility to handle the returning parameter.

|||

I did try the following and it works fine:

InsertCommand="INSERT INTO [table]([fieldName]) VALUES(@.value); Select @.myId = @.@.Identity;"
Add a additional parameter to the InsertParameters of the SQLDataSource:
<InsertParameters><asp:Parameter Name="name" Type="type"/><asp:Parameter Direction="output" Name="myId" Size=4 Type=int64/></InsertParameters>

Handle the inserted event of de sqldatasource:
Protected Sub SqlDataSource_Inserted(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)Handles SqlDataSource.InsertedDim idAs Integerid = e.Command.Parameters("@.myId").ValueEnd Sub
|||

Thank you so much! I had tried the same thing but couldn't getit to work -- turns out I left out the @. symbol after the semi-colon inthe follow-on select statement within the SqlDataSource. Once Istuck that in there it worked perfectly!

Much obliged!

Monday, February 20, 2012

no sync replication instructions.

Hello.
Does anyone have instructions on how to set back up replication that has
been marked for re-initilization thru the gui (enterprise manager)? We
have a subscriber that had their wan link down for the whole weekend and
now all their publications are marked for reinitialization. Some the
tables in question are 20gb in size, and that is just too big for us to
re-do snapshots and send over a WAN link. So in reading Hilary's and
Pauls post it looks like a "no-sync" will help me not have to send over
a snap shot.
1. how do i do this through enterprise manager only?
2. is there anyway for me to tell replication to go back lets say the
last 48hrs for the tables that we replicate, and "repush" that data
over?
Thanks,
-comb
Comb,
this article should help:
http://www.replicationanswers.com/No...alizations.asp
Initially I'd use Redgate's DataCompare to sync the data for any stray
changes.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||In article <eo9dqUZrFHA.1256@.TK2MSFTNGP09.phx.gbl>,
Paul.Ibison@.Pygmalion.Com says...
> Comb,
> this article should help:
> http://www.replicationanswers.com/No...alizations.asp
> Initially I'd use Redgate's DataCompare to sync the data for any stray
> changes.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
>
Thanks Paul. I appreciate yours and hilary's help.
looking now. I am also going to look into this Redgates.
-comb

no such interface supported virus

I'm running an access 2000 front end with a slq server 2000 back end on a lo
cal network. All of the sudden one workstation couldn't connect to the serv
er. So after trying several things I think I've came to the correct conclus
ion. I believe that the ma
chine was infected by a virus that was missed by two different scanners. I
think its a hijack virus that takes control of sql when its trying to connec
t to the server using the server name. Its very odd and isn't detected by s
canners. A temp. fix is to
just use the ip of the server to connect and then it works. Also if I try a
nd ping the server by name it doesn't get a return however if I use the elon
gated full name of the server with domain its fine. Any ideas suggestions c
lues?Is the server running a Personal Firewall?
Are you connecting via TCP or Named Pipes?
What are you using for Name Resolution of the server?
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.