Friday, March 30, 2012
information_schema question
I wanted to know what is the object type for information_schema. I could
not locate this object in any database.
Please share if anyone knows.
on all DB's
select * from sysobjects where lower(name)='information_schema'
Tks
Mangesh"INFORMATION_SCHEMA" isn't the name of an object, it's the name of a schema -
the namespace that contains the set of info schema views. You'll find that
the views are actually defined in Master.
--
David Portas
SQL Server MVP
--
"Mangesh Deshpande" wrote:
> Hi
> I wanted to know what is the object type for information_schema. I could
> not locate this object in any database.
> Please share if anyone knows.
> on all DB's
> select * from sysobjects where lower(name)='information_schema'
> Tks
> Mangesh
information_schema question
I wanted to know what is the object type for information_schema. I could
not locate this object in any database.
Please share if anyone knows.
on all DB's
select * from sysobjects where lower(name)='information_schema'
Tks
Mangesh"INFORMATION_SCHEMA" isn't the name of an object, it's the name of a schema
-
the namespace that contains the set of info schema views. You'll find that
the views are actually defined in Master.
David Portas
SQL Server MVP
--
"Mangesh Deshpande" wrote:
> Hi
> I wanted to know what is the object type for information_schema. I could
> not locate this object in any database.
> Please share if anyone knows.
> on all DB's
> select * from sysobjects where lower(name)='information_schema'
> Tks
> Mangeshsql
information_schema question
I wanted to know what is the object type for information_schema. I could
not locate this object in any database.
Please share if anyone knows.
on all DB's
select * from sysobjects where lower(name)='information_schema'
Tks
Mangesh
"INFORMATION_SCHEMA" isn't the name of an object, it's the name of a schema -
the namespace that contains the set of info schema views. You'll find that
the views are actually defined in Master.
David Portas
SQL Server MVP
"Mangesh Deshpande" wrote:
> Hi
> I wanted to know what is the object type for information_schema. I could
> not locate this object in any database.
> Please share if anyone knows.
> on all DB's
> select * from sysobjects where lower(name)='information_schema'
> Tks
> Mangesh
Wednesday, March 28, 2012
Information
Question,
If i have a spid like this:
1)Sleeping
2)Last_wait type: PAGEIOLATCH_SH
3)wait ressource: 7:1:1246732
4)cmd: AWAITING COMMAND
5) it=B4s a day old and is comming from someone's pc
could it be possible that even though that spid is sleeping its holding a "lock" on the ressource 7:1:1246732?
ThanxsYou can run the sp_lock procedure and see if this spid has a lock on any
resources.
Rand
This posting is provided "as is" with no warranties and confers no rights.
Friday, March 23, 2012
Infinite Loop in BOL code!?
Take a look at error handling .. what happens if one of the three cmd.execute within the [Done:] hanlde fails?
It looks to me like we would have an infinite loop! .. am I missing something here?
BOL CODE EXAMPLE:
----------
Dim Cn As New ADODB.Connection
Dim Cmd As New ADODB.Command
' If the ADOTestTable does not exist, go to AdoError.
On Error GoTo AdoError
' Connect using the SQLOLEDB provider.
cn.Provider = "sqloledb"
cn.Properties("Data Source").Value = "MyServerName"
cn.Properties("Initial Catalog").Value = "northwind"
cn.Properties("Integrated Security").Value = "SSPI"
cn.Open
' Set up command object.
Set Cmd.ActiveConnection = Cn
Cmd.CommandText = "DROP TABLE ADOTestTable"
Cmd.CommandType = adCmdText
Cmd.Execute
Done:
Cmd.CommandText = "SET NOCOUNT ON"
Cmd.Execute
Cmd.CommandText = "CREATE TABLE ADOTestTable (id int, name char(100))"
Cmd.Execute
Cmd.CommandText = "INSERT INTO ADOTestTable values(1, 'Jane Doe')"
Cmd.Execute
Cn.Close
Exit Sub
AdoError:
Dim errLoop As Error
Dim strError As String
' Enumerate Errors collection and display properties of
' each Error object.
Set Errs1 = Cn.Errors
For Each errLoop In Errs1
Debug.Print errLoop.SQLState
Debug.Print errLoop.NativeError
Debug.Print errLoop.Description
Next
GoTo Done
End Sub
-----------------Where?|||Originally posted by Brett Kaiser
Where?
If an error occurs within the [Done:] handle then the compiler goes to [AdoError:] handle and when executing the last statement there "GoTo Done" we will end up going back to [Done:] ... then same error occurs .. then back to [AdoError:] .. etc .. that sure looks like an infinite loop!|||If a user who can not create tables runs this, yes, it could run forever. Fortunately, Microsoft makes everything run as "administrator".|||lack of permission to Insert would cause the same problem .. But it's not just lack of permission that might cause this code to run forever .. for instance a network failure might raise the same problem .. a server failure might also do the same thing .. the point is: Error handling is supposed to be very helpful but in this code it is not. Because it is not done right.
Indirect Configuration with ConfigType 'Indirect SQL Server' fails
Hi,
I have a package that uses a Configuration of type SQL Server where the property values are held.
This runs successfully using this direct configurations.
When I use an Indirect configuration using an environment variable to point to this SQL Server configuration type the package won't even validate.
The Indirect Configuration is:
[EHC-SQLD-01.].[SSISConfigsDEV];[dbo].[SSIS Configurations DEV];pkgLRD CED Import;
which follows the standard of : db connections, config table, filter
This works by the way on my client but on the dev server the error is:
Error: The connection "[EHC-SQLD-01].SSISConfigsDEV" is not found. This error is thrown by Connections collection when the specific connection element is not found.
I've tried every combination for the env variable using quotes, full computer name etc (I thought it was the hyphens in the name), but can't seem to get it to work.
I've also tried as both user and system env variables but made no difference (which one should we use for SSIS anyway as BOL doesn't state this ?)
Appreciate any help. I'm trying to deploy this on the Dev server for testing.
Thanks
P R W.
P R W,
I have never used the Indirect method for a SQL Server based configuration; but I use a similar approach that involves an env variable and the direct method:
1. Set the SQL server based configuration using the direct method using a connection manager called, Let's say 'Configuration'
2. Create an Env variable based configuration to set the connection string of 'Configuration' connection manager and place it at the very top of the configuration organizer, so it happens before the SQL server based one.
Make sure you create the Env variable wit the proper connection string for ‘Configuration’; and that you close and re-open BIDS so you can see the Env variable in thedropdow list for step 2.
I started using this method a while before knowing about indirect configurations and it has worked fine; maybe that is why I have not looked into the indirect ones.
|||
I'm not sure why you would want to do that.
If you deploy the package to different environments e.g. from dev to producution, you must still go into the package to change the Env variable to amend the connection string as eg. the package will now sit on a different server.
Also, you env variable sits first so the configs used will actually be the configs that run last i.e. the SQL Server based one, so what's the point of having two configs that do the same thing ?
The point of indirect configs is that you don't have to open the package. All you do is amend the Environment variable defined on the OS. This should make package deployment easier and more secure.
The actual problem lies in the fact that the Package does not recognise the Indirect config for the environment variable. Although I have successfully set this up on my client, it is not working for the Dev server.
|||P R W wrote:
I'm not sure why you would want to do that.
If you deploy the package to different environments e.g. from dev to producution, you must still go into the package to change the Env variable to amend the connection string as eg. the package will now sit on a different server.
I guess I was not clear enough. You DO NOT have to open the package and change the Env Variable name; you have to make sure all servers you want to deploy the solution to have the same env variable (same name); then you need to make sure the connection string in the Env variable is right. That's exactly how the same way the Indirect configurations works; you reference a Env variable and then you just change its value, right?
P R W wrote:
Also, you env variable sits first so the configs used will actually be the configs that run last i.e. the SQL Server based one, so what's the point of having two configs that do the same thing ?
Ok let's try again. First, I don't have 2 configurations doing the same thing. Let me give you an scenario: My package has about 10 component/properties that need to be configured at run time; so I create a SQL Server configuration table with all those entries and define same number of SQL server configurations on every of those properties using the direct method. Since I am using the direct method I am asked to provide connection information to get access to the configuration table; is at that point where I use the 'configuration' connection manager. So far, I have create my 10 configurations based on a SQL Server table; to get access to that configuration table I am using 'Configuration' connection manager; the problem with that is that the connection string of 'configuration' needs to be changed at run time depending on which server/Environment is the package being executed. It is at this point when I create an Env. variable to set the connection string of 'configuration' and place it at the very top. That way on each run SSIS will go to the Env variable; will take the connection string, set it to 'configuration' and then all other sql server based configurations will use the right connection to get access to the table.
Notice that an Env variable with the same name needs to exists on every server your are deploying the solution to. But the same constraint exists using the indirect method. I can tell you more; using the indirect method you are constraint to use only Env variable; with this approach you could use alternatively an XML configuration file; that comes handy when you hit the wall when some weird IT policies that prevent you using Env variables
If you don't believe just give it a try; it will take just a couple of minutes to run a test.
P R W wrote:
The point of indirect configs is that you don't have to open the package. All you do is amend the Environment variable defined on the OS. This should make package deployment easier and more secure.
That is exactly what I am doing; just change a value in a Env variable.
P R W wrote:
The actual problem lies in the fact that the Package does not recognise the Indirect config for the environment variable. Although I have successfully set this up on my client, it is not working for the Dev server.
That is why I started my first post saying that I have not used the indirect method; and that I was offering an alternative approach that has worked for me.
|||
I still don't seem to follow what you are saying, as I'm confused by the terminology you're using.
If I have followed it correctly (and I must admit I had to read it several times through - maybe cos its a Fri and everyone else has gone home )., this is the scenario I have:
This is what I have set in Package Configs (this is my direct SQL Server Config):
Configuration Name : Configuration1
Configuration Type: SQL Server
Configuration String : EHC-SQLD-01.SSISConfigsDEV;[dbo].[SSIS Configurations DEV];pkgLRD CED Import;
(The table [SSIS Configurations DEV] holds all the necessary properties and values).
So you are now saying, create another Package Configuration using Config Type of Environment Variable. ?
Type in a name - any name (lets say 'EnvVarTest') and set the Property of that variable to the Connection string of Configuration1 ?
If I've read that correct, when setting up the Env Variable on the OS, the Env variable name is X and Value 'EnvVarTest'. ?
I'm not sure that is what you are saying though, because you would still need to edit the package when deploying from one machine to another ?
Regards,
P R W.
|||P R W wrote:
I still don't seem to follow what you are saying, as I'm confused by the terminology you're using.
If I have followed it correctly (and I must admit I had to read it several times through - maybe cos its a Fri and everyone else has gone home
)., this is the scenario I have:
This is what I have set in Package Configs (this is my direct SQL Server Config):
Configuration Name : Configuration1
Configuration Type: SQL Server
Configuration String : EHC-SQLD-01.SSISConfigsDEV;[dbo].[SSIS Configurations DEV];pkgLRD CED Import;
(The table [SSIS Configurations DEV] holds all the necessary properties and values).
So you are now saying, create another Package Configuration using Config Type of Environment Variable. ?
Type in a name - any name (lets say 'EnvVarTest') and set the Property of that variable to the Connection string of Configuration1 ?
If I've read that correct, when setting up the Env Variable on the OS, the Env variable name is X and Value 'EnvVarTest'. ?
I'm not sure that is what you are saying though, because you would still need to edit the package when deploying from one machine to another ?
Regards,
P R W.
Sorry if it sounded too confussing.
See if this clarifies it:
http://rafael-salas.blogspot.com/2007/01/ssis-package-configurations-using-sql.html
Otherwise, I will give up
|||
OK, now I followed that. That was useful and solved the problem by using Direct config rather than Indirect Configuration.
I wasn't setting up the Environment Variable value correctly on the OS.
Appreciate the time you've taken to help.
(You really weren't thinking of giving up though were you ).
Still unsure as to why the Indirect Configuration failed to validate when it worked correctly on local machine. Tried all sorts of combinations for the Configuration. Anyway that's for another day.
Thanks.
P R W.
|||PRW,
Glad you found it helpful. I also took the time to research about the indirect configurations, and I think I understood how the work, thanks to a blog post I found. Basically, the Env variable has to contain the SSIS connection manager to be used, the configuration table name, and the configuration filter. Saying that, it looks like you have to create an Env. variable for every property you want to override at run time; which make me wonder if using plain Env variable based configuration would not give the same results in a more simpler way.
The workaround I described in my blog requires only one Env variable only; then all configuration values are stored in the table.
Here is the link, in case you want to look into that other post hat talks about SQL Server Indirect configurations:
http://dotnetjunkies.com/WebLog/appeng/archive/2006/05/30/indirectconfigpackagessis.aspx
|||
You don't have to have an Env variable for every property required to by dynamic.
Basically it works in a similar way as you have used Direct configs eg. you setup a SQL Server Config type with table containing all properties required to be dynamic and their values. Then you set this up as Indirect config in Package configs. Then setup an env variable on the OS, that makes a connection to the SQL Server Config type Package config with value:
Servername.DBname;Tablename;Filtervalue;
so as you see very similar to the methodology you have used.
I have actually used it successfully as I said in my local environment and it works well. You don't need to reopen the package and all configs can be set in any of the other config types such as SQL, XML.
|||P R W wrote:
You don't have to have an Env variable for every property required to by dynamic.
Basically it works in a similar way as you have used Direct configs eg. you setup a SQL Server Config type with table containing all properties required to be dynamic and their values. Then you set this up as Indirect config in Package configs. Then setup an env variable on the OS, that makes a connection to the SQL Server Config type Package config with value:
Servername.DBname;Tablename;Filtervalue;
so as you see very similar to the methodology you have used.
I have actually used it successfully as I said in my local environment and it works well. You don't need to reopen the package and all configs can be set in any of the other config types such as SQL, XML.
I think I am missing something here. If the Environment variable requires 'FilterValue' as part of its value; how can you set multiple values/properties at run time using only one Env variable? Can you provided a list of values for the 'Filtervalue' part?
|||
The Filter Value you provide in the OS Env variable, is used to determine the value held in the column 'ConfigurationFilter' of the SQL Server table that has been defined as the SSIS Configuration.
This table also has cols of :
ConfiguredValue - the actual property/variable value etc.
Package Path - the actual property/variable etc.
Configured Value Type.
The ConfigurationFilter is just a value I believe that determines what SSIS Configuration that the values in the table belong too. eg. I would have a table as below containing my SSIS Configs for a package named 'pkgLRD CED Import'
pkgLRD CED Import Void \Package.Variables[User::VarUnencryptionArguments].Properties[Value] String
pkgLRD CED Import C:Test\ \Package.Variables[User::VarSourceConnection].Properties[Value] String
pkgLRD CED Import C:\pkgLRD CED Import.chk \Package.Properties[CheckpointFileName] String
It made sense to me to use the Package name (since this ideally should be unique) though you could actually use any value. Thus you could hold all the Config values for all Package configs in one central table. The Filter value (in this case package name) therefore determines which configs the package should pick up.
So the OS Env variable would look like:
Servername.Dbname;Configtablename;ConfigFilter(i.e.packagename);
This worked for me although I must admit I haven't tested it for multiple packages yet, only one package.
The problem is as you have sort of stated that you would need one OS Env Variable for every package (though not every property).
This could possibly become a bit of a mess.
You could just have one OS Env variable and not define the Config Filter (haven't tested this though), but then I believe you would have to have a separate table for each package. This maybe a requirement or maybe not.
This is why I actually prefer your solution using the Direct method that you have since explained. It allows me to have one single OS env variable on each Server, and one central table for all SSIS package configs.
Regards,
P R W.
BTW I'm still learning SSIS (5 months in) so don't consider myself any sort of expert.
Monday, March 12, 2012
Indexing - What is fastest? Numeric or Alpha fields?
If I create an index on a field in SQL Server, what will be the most efficient (fastest) field type to index a field? (This field will be a "Pointer" to a child table that will contain a list of codes, and their description.)
Would a Numeric field be quicker than a VarChar field?
VarChar would make it easier for a Human to decipher the raw records. (For example, if I used a numeric the code would be 42 or 47, while the VarChar could be'savings' or'checking'.)
Basically I will have the following "Master" table:
FieldType---IDIntNameVarCharStatusInt -or- VarCharCustomer_TypeInt -or- VarChar
If Customer_Type is a code that can be looked up in another table, and I index that field, would I want the "Code" to be an Int or VarChar?
SQL:
Select *From MasterWhere Customer_Type = <42> or <'savings'>
MyWhereclause would depend on the field type.
Thank you,
Bryan
Friday, March 9, 2012
Indexes, primary keys constraint type from sysconstraints -table?
and where is the information of constraints type in sysconstarint table?
I readed drom help that field sysconstraints.status should tell it, but I
have mystique values in this field,
such as 3105, 2069, 133141 etc... Data type is bitmap, how I can compare
bitmaps and integers?
Hi
Don't query system tables directly.
Use the Information Schema Views, together with OBJECTPROPERTY and
COLUMNPROPERTY
All the information is easily usable then.
Look those up in BOL.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Major" wrote:
> Where I can found information that what indexes are primary keys,
> and where is the information of constraints type in sysconstarint table?
> I readed drom help that field sysconstraints.status should tell it, but I
> have mystique values in this field,
> such as 3105, 2069, 133141 etc... Data type is bitmap, how I can compare
> bitmaps and integers?
>
>
|||hi
i think you can find it by using this query
select * from information_schema.table_constraints
Siddharth
"Major" wrote:
> Where I can found information that what indexes are primary keys,
> and where is the information of constraints type in sysconstarint table?
> I readed drom help that field sysconstraints.status should tell it, but I
> have mystique values in this field,
> such as 3105, 2069, 133141 etc... Data type is bitmap, how I can compare
> bitmaps and integers?
>
>
Wednesday, March 7, 2012
Indexes and UniqueIdentifier Fields
articles, whatever). I need to use a column of type uniqueidentifier
because one of the requirements is that I be able to write the articles
out to XML or import them from XML, and references (as in, "for more
info read this: 2323-232-90934" have to still work after the export and
import).
So as a minimum, the table is going to look like this:
CREATE TABLE Articles (
ArticleID uniqueidentifier,
PublishDate datetime,
Title nvarchar (50)
ArticleContent ntext
)
GO
ALTER TABLE Articles ADD
CONSTRAINT PK_Articles
PRIMARY KEY NONCLUSTERED (ArticleID)
WITH FILLFACTOR = 100
GO
As you can see, I'm not going to use a clustered index on a column of
type UniqueIdentifier. I got that much from this newsgroup and from
websites on sql server performance tuning.
Two questions. 1: I will obviously need to list recent articles. I'll
need to do: select top 10 ArticleID, PublishDate, Title from Articles
order by PublishDate desc
Will there be any problem with an index on a datetime field to make
that query faster?
CREATE UNIQUE CLUSTERED INDEX IX_Articles_PublishDate
ON Articles (PublishDate DESC)
WITH FILLFACTOR = 100
GO
Question 2: Is there anything else that I can do here that I'm missing?
Should I maybe also have a auto-increment field and put the clustered
index on it instead?
Thanks in advance
chrischristopher.secord@.gmail.com (christopher.secord@.gmail.com) writes:
> So as a minimum, the table is going to look like this:
> CREATE TABLE Articles (
> ArticleID uniqueidentifier,
> PublishDate datetime,
> Title nvarchar (50)
> ArticleContent ntext
> )
> GO
> ALTER TABLE Articles ADD
> CONSTRAINT PK_Articles
> PRIMARY KEY NONCLUSTERED (ArticleID)
> WITH FILLFACTOR = 100
> GO
> As you can see, I'm not going to use a clustered index on a column of
> type UniqueIdentifier. I got that much from this newsgroup and from
> websites on sql server performance tuning.
Certainly clustered index on Uniqueidentifier and a fillfactor of 100
is a recipe for disaster. However, SQL Server MVP Greg Linwood pointed
out to me that with a low fill factor, uniqueidentifier very can be a
good choice for a clustered index. New rows will be inserted in existing
gaps. But this requires that you reindex when the gaps are starting
to run out.
> Two questions. 1: I will obviously need to list recent articles. I'll
> need to do: select top 10 ArticleID, PublishDate, Title from Articles
> order by PublishDate desc
> Will there be any problem with an index on a datetime field to make
> that query faster?
> CREATE UNIQUE CLUSTERED INDEX IX_Articles_PublishDate
> ON Articles (PublishDate DESC)
> WITH FILLFACTOR = 100
> GO
PublishDate could indeed be a good choice for the clustered index,
but I don't think you should make it unique. Surely, you must be able
to store two articles published the same day! (I'm assuming that you
will keep the time portion to midnight.)
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for the advice. I've decided to add a column of type int
(indentity) and make that the clustered index. The result will be the
same as what I was looking for in indexing publishdate, but it's on an
simple integer field.
chris|||christopher.secord@.gmail.com (christopher.secord@.gmail.com) writes:
> Thanks for the advice. I've decided to add a column of type int
> (indentity) and make that the clustered index. The result will be the
> same as what I was looking for in indexing publishdate, but it's on an
> simple integer field.
Say that you have a query:
SELECT * FROM tbl WHERE publishdate BETWEEN '20050601' AND '20050630'
If you have a clustered index on publishdate, SQL Server will do a
clustered index seek in this interval and find the rows quickly. If you
cluster on the identity column instead, SQL Server will have to scan
the entire table. If you add a non-clustered index on publishdate, SQL
Server may use that index, but if the interval is too wide, it will estimate
that nc-index + bookmark lookup is too expensive, and scan the table
nevertheless.
This is because, there is no way that SQL Server can assert that the
date follows the identity column.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Have you thought about getting a textbase (document management tool) to
do this? SQL is not the answer to everything.
Friday, February 24, 2012
indexes and query optimization
I am wondering if I should have a clustered index on this table since there are so many columns used in where clauses. Would it be useful to cluster on the column it is sorted by, or should I just stick with nonclustered indexes?
ThanksIf you have sort order by different columns, clustered index will not help.
You can have only one clustered index over a table.
But you can still have none clustered indexes over columns you do order by over.
Indexes
(or indexes) has?
We recently changed/added some indexes to a table, and since then,
performance has gone down hill...but I need proof that it was the indexes
before removing.
Thanks.You can run profiler to look at your worst performing queries. It can
capture the query text and execution plan. Then, look at the execution
plans for the queries. If the plans are less efficient, i.e. higher cost,
than they were before and use the new indexes, there is a good chance that
the indexes are at fault.
Christian Smith
"SQL" <nospam@.asdfadsf.com> wrote in message
news:OZBDsOP7DHA.3804@.tk2msftngp13.phx.gbl...
> Hi, is there any type of monitor I can use to determine what affect an
index
> (or indexes) has?
> We recently changed/added some indexes to a table, and since then,
> performance has gone down hill...but I need proof that it was the indexes
> before removing.
> Thanks.
>|||execution plan is key.
look for table scans (or index scans)
apply new index and hopefull the scans turn into SEEKS.
that is generally a good thing.
obviously this post is over-simplified, but that's it in a nutshell.
cheers,
Greg Jackson
PDX, Oregon
Indexes
(or indexes) has?
We recently changed/added some indexes to a table, and since then,
performance has gone down hill...but I need proof that it was the indexes
before removing.
Thanks.You can run profiler to look at your worst performing queries. It can
capture the query text and execution plan. Then, look at the execution
plans for the queries. If the plans are less efficient, i.e. higher cost,
than they were before and use the new indexes, there is a good chance that
the indexes are at fault.
Christian Smith
"SQL" <nospam@.asdfadsf.com> wrote in message
news:OZBDsOP7DHA.3804@.tk2msftngp13.phx.gbl...
> Hi, is there any type of monitor I can use to determine what affect an
index
> (or indexes) has?
> We recently changed/added some indexes to a table, and since then,
> performance has gone down hill...but I need proof that it was the indexes
> before removing.
> Thanks.
>|||execution plan is key.
look for table scans (or index scans)
apply new index and hopefull the scans turn into SEEKS.
that is generally a good thing.
obviously this post is over-simplified, but that's it in a nutshell.
cheers,
Greg Jackson
PDX, Oregon