sql-server-2005

ASP SQL Error Handling

Hello, I am using Classic asp and SQL Server 2005. This is code that works (Provided by another member of Stack Overflow): sqlStr = "USE "&databaseNameRecordSet.Fields.Item("name")&";SELECT permission_name FROM fn_my_permissions(null, 'database')" This code checks what permissions I have on a given database - the problem being -...

check if a value is NULL or Less than 0 in one TSQL statement

ISNULL(SUM(MyTable.Total), 0) AS Total how can i modify the above statement to also check if Total is less than 0 (zero), such that if Total is NULL or less than 0 (negative), i assign 0 to Total ...

locked stored procedures in sql

Hi, I am not too familiar with sql server 2005. I have a schema in sql which has stored procedures with small lock on them. As I understand they were created using C#, all these locked procedures have a source file in C# with the code of the procedures. The thing is I can't access them. I need to modify one of these procedures but it ...

Dynamically set the result of a TSQL query using CASE WHEN

SELECT MyTable.Name, ( SELECT CASE WHEN ISNULL(SUM(TotalDays), 0) <= 0 THEN 0 ELSE SUM(TotalDays) END AS Total FROM Application AS Applications WHERE (ID = MyTable.id) ) - MIN(Assignments) AS Excesses FROM MyTable The above TSQL statement is a subq...

Find details of a query or statement that caused an unexpected table update

We have been having problems with ghost updates in our DB (SQL Server 2005). Fields are changing, and we cannot find the routine that is performing the update. Is there any way, (perhaps using an update trigger ?) to determine what caused the update? The SQL statement, process, username/login,etc? ...

Changing default logical filename in SQL 2005

I have a issue about creating databases in SQL 2005. I want to be able to change the default logical filename for the mdf file. At the moment the log logical filename ends in _log by default. I want the data logical filename to automatically end with _data for consistency. Is there a way i can set this? Andrew ...

Is it possible to force an error in an Integration Services data flow to demonstrate its rollback?

I have been tasked with demoing how Integration Services handles an error during a data flow to show that no data makes it into the destination. This is an existing package and I want to limit the code changes to the package as much as possible (since this is most likely a one time deal). The scenario that is trying to be understood is...

Error Handling in T-SQL Scalar Function

Ok.. this question could easily take multiple paths, so I will hit the more specific path first. While working with SQL Server 2005, I'm trying to create a scalar funtion that acts as a 'TryCast' from varchar to int. Where I encounter a problem is when I add a TRY block in the function; CREATE FUNCTION u_TryCastInt ( @Value as VARCH...

Detecting if SQL Server Compact Edition 3.5 SP2 x64 is installed?

I am building an installer and I want to bootstrap SQL Server Compact Edition 3.5 SP2. The problem is that I am looking for the registry key HKLM\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU\DesktopRuntimeVersion. The reason that is a problem is that for 64-bit machines SQL CE requires that both the 32-bit and 64-bit...

Best solution to import records from MySQL database to MS SQL (Hourly)

I need to import records stored in a MySQL Database that I do not maintain into my Sql Server 2005 database (x64) We should import the records at an interval basis (probably 1 hour). What would be the best solution to perform the regular import? Windows Service (using reference MySql.data dll) Windows Client (could make it automated)...

SQL Server LIKE for Integer

I have a column which is integer and I want to search all numbers starting with 1500. I know I could use something like left(accountid, 4)= 1500. But is that an optimum solution or is there a better approach? I am using SQL Server 2005. ...

Stored Procedure for one-to-many relation

Hi I'm using GlassFish ESB to for example to store data recieved from a Microsoft WCF webservice in SQL Server 2005. The problem I'm faced with is firstly that i have to insert into three tables, the usual approach would be to create a DB Binding in a "BPEL" but that has the problem of me having to create one binding for each table so I...

Do database engines other than SQL Server behave this way?

I have a stored procedure that goes something like this (pseudo code) storedprocedure param1, param2, param3, param4 begin if (param4 = 'Y') begin select * from SOME_VIEW order by somecolumn end else if (param1 is null) begin select * from SOME_VIEW wher...

Other solution instead of Cursoring

Hi there I have the following pivoting table that I manage to do and here's the result and I want to put a bit further. RID; NTRITCode; NTRIId; Parameter; Usage; Rate** 1; CURRENT; 4; Peak; 100; 0.1 1; CURRENT; 4; NonPeak; 200; 0.2 1; PROPOSED; 6; Peak; 100; 0.2 1; PROPOSED; 6; NonPeak; 200; 0.3 1; PROPOSED; 8; Peak; 200; 0.3 1; PRO...

How many inserts can you have in a sql transaction.

I have a task to do that will require me using a transaction to ensure that many inserts will be completed or the entire update rolled back. I am concerned about the amount of data that needs to be inserted in this transaction and whether this will have a negative affect on the server. We are looking at about 10,000 records in table1 a...

How do I create an index on a table that is non unique?

I want an index on a non-primary key column, but this column may have nulls in it. I find on a normal unique index, it (rightly so) only allows one null. Is that possible? and what is the syntax for this? ...

Good websites for learning SQL 2005

Hi Friends, Could anybody help me by giving some good websites that are describing about T-SQL commands. I am a new guy in this field. thanks in advance.. ...

any .net Framework Application at some Point Memory?Other Errors Out with no errors

I have a strange problem/bug when I have many I believe .net Applications Open at once. I may at one point have 3 Visual Studio 2005 Projects open (big or small doesn't really matter) 2 Visual Studio 2003 Projects open & sql2005 Management Studio. Or various combinations of either/or. Always when I've got quite a bit open. What hap...

Simple tool/steps for obfuscating/scrubbing production data

I am involved in a project where I need to provide subset of our production data (for a date range) to one of my co-workers for trouble shooting.I would like to insert a scrubbed subset of the production data into a new database table that my co-worker can access. Please suggest best approach to achieve this. ...

Copy data from one SQL Server database table to the other

I would like to copy the data from one table to another between different servers. If it is with in the same server and different databases, i have used the following SELECT * INTO DB1..TBL1 FROM DB2..TBL1 (to copy with table structure and data) INSERT INTO DB1..TBL1(F1, F2) SELECT F1, F2 FROM DB2..TBL1 (copy only data) Now my quest...