sql-server-2005

Indexing strategy on table

I have an SQL Server 2005 table named 'EventTable' defined as such: EventID, EventTypeCode, EventStatusCode, EventDate Currently the table has a clustered index on the primary key 'EventID', there are no other indexes currently EventTypeCode and EventStatusCode columns are CHAR(3) (examples are 'NEW', 'SEN', 'SAL') and are foreign key...

SSIS Transfer Task That Handles Schema Changes

I'm using SSIS with SQL Server 2k5 to build a transfer task to copy all of the data from one database to another. This works quite well, except for one problem - the source database will periodically have schema changes (generally just additions like new columns) but the transfer task seems to choke if the two schemas don't match exactly...

What is the best way to maintain a LastUpdatedDate column in SQL?

Suppose I have a database table that has a timedate column of the last time it was updated or inserted. Which would be preferable: Have a trigger update the field. Have the program that's doing the insertion/update set the field. The first option seems to be the easiest since I don't even have to recompile to do it, but that's not r...

problem selecting xml from sql server 2005 (row shows up as null)

I have a ridiculously long xml row, it has > 800000 characters. The 'client' is also the 'server'. The OS is windows 2k8 x64. The database has plenty of memory as does the client. The problem is that once i hit some magic number of characters - exactly 43679 xml chars - the row returns what APPEARS to be ''. i call them 'xml chars' b...

Detecting KPI cell from Cellset when querying SQL 2005 Analysis Services

Given an MDX query that may return KPI values, is there a way to query the cells in the cellset object to determine whether they are actually KPI's? This way I can display trend/status images in the results instead of 0. -1 etc. ...

undo changes on table in database

my application has the following procedure. a database of products (20,000 rows) exists. our client has 'import' feature where he imports an excel file. this is implemented by deleting all products table rows, then doing the import - which is a long thing since we programmatically performing calculations on the data. the obvious prob...

Force SQL Server column to a specific value

Is it possible to force a column in a SQL Server 2005 table to a certain value regardless of the value used in an insert or update statement is? Basically, there is a bug in an application that I don't have access to that is trying to insert a date of 1/1/0001 into a datetime column. This is producing a SqlDateTime overflow exception. ...

C# Equivalent of SQL Server 2005 DataTypes

For the following SQL Server 2005 datatypes, what would be the corresponding datatype in C#? Exact Numerics bigint numeric bit smallint decimal smallmoney int tinyint money Approximate Numerics float real Date and Time date datetimeoffset datetime2 smalldatetime datetime time Character Strings char varchar text Unico...

Is there a 64 bit version of SQL Server Management Studio (SSMS) 2005?

Is there a x64 or ia64 version of SQL Server Management Studio (SSMS) 2005? All the information I'm seeing leads me to believe there is only a x86 version. This link is my evidence that a 64-bit version doesn't exist - http://support.microsoft.com/?id=906892 ...

What is the benefit of update instead of doing delete and then Insert in the same table.

Hi, I have a table say example "ABC", I have a row that needs to be stored in to this "ABC" table. I plan to update it instead of doing delete from the table and then insert. What is the impact that this will make on database? In, table level, page level, time, cost and every thing. thanks Thiru ...

SQL Identity Column out of step

We have a set of databases that have a table defined with an Identity column as the primary key. As a sub-set of these are replicated to other servers, a seed system was created so that they could never clash. That system was by using a starting seed with an increment of 50. In this way the table on DB1 would generate 30001, 30051 etc, ...

Using Triggers To Enforce Constraints

I'm trying to enforce integrity on a table in a way which I do not think a Constraint can... CREATE TABLE myData ( id INTEGER IDENTITY(1,1) NOT NULL, fk_item_id INTEGER NOT NULL, valid_from DATETIME NOT NULL, invlaid_from DATETIME NOT NULL ) The constraint I wan...

Counting rows for all tables at once

I'm using SQL Server 2005 and would like to know how I can get a list of all tables with the number of records in each. I know I can get a list of tables using the sys.tables view, but I'm unable to find the count. Thank you ...

SQL Server 2008 Auto Generate Change Scripts Legacy Problem

We enable "Tools ==> Options ==> Designers ==> Table and Database Designers ==> Auto Generate Change Scripts" in our SQL Server Management Studio (SSMS). When changing our database schema, we save the script and, thanks to DB migration tools we've got installed on all the machines running our applications, we can synchronize the schema d...

Getting description field from Active Directory in MSSQL2005 (LDAP)

The only field i cannot grab is the 'description' field from our AD. The error is: Cannot get the data of the row from the OLE DB provider "ADsDSOObject" for linked server "ADSI". Could not convert the data value due to reasons other than sign mismatch or overflow. Is their some datatype i can use to handle the object it is trying to r...

SQL Server Mgt Studio not showing table?

I have a table in SQL Server 2000 Standard Edition called "dbo.T668" (don't blame me for the naming convention). I'm working on the server using SQL Server Management Studio 2005, and for some strange reason, I can't see the table at all in the list of tables. I see all the other tables, but not this one. If I open up a query editor a...

Should CONTROL permission be given on a Stored Procedure in SQL Server 2005?

I'm running into an issue where granting EXECUTE permissions on a specific Stored Procedure in SQL Server 2005 is not working. Some of the testers messed around with the permissions - and found that if they also granted CONTROL permissions on the Stored Procedure - then it ran fine. They are now convinced that granting CONTROL permissi...

Using the results of a query in OPENQUERY

I have a SQL Server 2005 database that is linked to an Oracle database. What I want to do is run a query to pull some ID numbers out of it, then find out which ones are in Oracle. So I want to take the results of this query: SELECT pidm FROM sql_server_table And do something like this to query the Oracle database (assuming that the ...

What is the best way to check for the existence of a Login in SQL Server 2005.

I am looking for the best way to check that a database login exists in SQL Server 2005. I am currently using IF suser_sid('loginname') IS NOT NULL but suser_sid() returns a value in some cases where a login does not exist. In SQL 2000 we use SELECT * FROM [Master].[dbo].[sysxlogins] WHERE [name] ='loginname' but that table does...

Prevent mutually recursive execution of triggers?

Suppose you have the tables Presentations and Events. When a presentation is saved and contains basic event information, such as location and date, an event will be created automatically using a trigger. (I'm afraid it's impossible for technical reasons to simply keep the data at one place and use a view.) In addition, when changing this...