sql

begin try catch on sql server 2005, how to send the ERROR_stuff to the calling parent?

you have this procedure CREATE PROCEDURE dbo.test1 AS BEGIN begin transaction begin try exec dbo.test2 commit transaction end try begin catch SELECT ERROR_NUMBER() AS ErrorNumber ,ERROR_SEVERITY() AS ErrorSeverity ,ERROR_STATE() AS ErrorState ,ERROR_PROCEDURE() AS ErrorProcedure ,ERROR_LINE() AS...

error executing sql server query

Hi Guys, I am getting an error using this query select dbresultsid, TestCase, BuildID, Analyzed, Verdict, (select count(Verdict) from results where BuildID = 'Beta1' and Verdict = 'PASS') AS PASS, (select count(Verdict) from results where BuildID = 'Beta1' and Verdict = 'FAIL') AS FAIL, ...

"Index was outside the bounds of the array" while Compare SQL schema by SQL compare tool

I got one problem from comparing database schema as i use Red gate SQL Compare 6 , after initialization of the compare databases error is coming as following "Index was outside the bounds of the array". Please provide your valuable comments to get resolve this issue. ...

difference in these queries

Hi, I am executing a query different way in MSSQL, but the second query is not giving result as the first one. Query 1: select dbresultsid, TestCase, BuildID, Analyzed, Verdict, (select count(Verdict) from results where BuildID = 'Beta1' and Verdict = 'PASS') AS PASS, (select count(Ver...

PHP - Application config file stored as - ini,php,sql,cached,php class,JSON,php array?

I am trying to decide on the best way to store my applications configuration settings. There are so many options. The majority of applications I have seen have used a simple require and a PHP file that contains variables. There seem to be far more advanced techniques out there. What have you used? What is most efficient? What is most ...

Try to find a specific values in a table that can exist in Field1 or Field2 or Field3...(and so on)

I have a list of phones that I have to see if they exist in the table "Phones" the problem is that there is more than one field that each value can be in the table, i.e. This value: 4164553627 can be in Field1 or in Field2 or Field3 or Field4... or Field25 This value: 9054558557 can be in Field1 or in Field2 or Field3 or Field4... or F...

Infinite Looping Trigger

I have an after update/insert trigger on table x. In this trigger I need to check if a certain column has been updated which is simple enough doing a deleted/inserted table comparison. However, if a certain column has been changed to a certain value I need to update the inserted row in table x. Doing so obviously creates a loop. The ...

SQL Server constraint Help

Hello there, I'm having problems coming up with an adequate restraint in SQL Server 2005. My problem involves the following tables: Table PKTable { pk integer primary key, property integer, } Table FKTable { pk integer primary key, fk integer references PKTable(pk), } I really want to make it impossible for a record, fk_rec...

CREATE SCHEMA gives 1064 error

CREATE SCHEMA IF NOT EXISTS `paragraph` DEFAULT CHARACTER SET 'utf8' COLLATE default collation ; this line results with error 1064. MySql 5.4.3-beta. ...

SELECT COUNT(DISTINCT name), id, adress from users

Hi, With PHP I'm trying to run a SQL query and select normal columns as well as COUNT. $sql_str = "select COUNT(DISTINCT name), id, adress from users"; $src = mysql_query($sql_str); while( $dsatz = mysql_fetch_assoc($src) ){ echo $dsatz['name'] . "<br>"; } The problem is that when I have "COUNT(DISTINCT name)," in my query, it ...

SQL Server CONVERT(NUMERIC(18,0), '') fails but CONVERT(INT, '') succeeds?

PRINT CONVERT(NUMERIC(18,0), '') produces Error converting data type varchar to numeric. However, PRINT CONVERT(INT, '') produces 0 without error... Question: Is there some SQL Server flag for this or will I need to do case statements for every varchar to numeric conversion? (aside from the obvious why?) ...

SQL Server 2000 compatible script

Hi, this T-SQL script works fine in SQL Server 2005 but in SQL Server 2000 it says incorrect Syntax near 'Try' 'End'. Any help please? Begin Transaction Begin Try UPDATE Test SET RefID = 'bc27de13-2323-4ce8-8c87-0171efbd812a' WHERE RefID = 'bc27de13-2323-4ce8-8c87-0171ffbd812a'; DELETE FROM Physician WHERE RefID = 'bc27...

Creating SQL Server 2000 database using SQL Server 2008.

My development machine has SQL Server 2008 Developer edition on it. A production server I am going to do some development for has SQL Server 2000 on it. Is there a way to create a 2000 database using my 2008 developer edition? Or do I need to create it on the 2000 server and move it to my development machine? ...

SQL: Sorting By Email Domain Name

What is the shortest and/or efficient SQL statement to sort a table with a column of email address by it's DOMAIN name fragment? That's essentially ignoring whatever is before "@" in the email addresses and case-insensitive. Let's ignore the internationalized domain names for this one. Target at: mySQL, MSSQL, Oracle Sample data from...

Problem with xml select in tsql - can't seem to orgenize multi nodes in the right order

Hello every one....this is my code, i am trying to make a simple 3 nodes select in XML and it is not working, i am getting the parent, the second nodes (all of them) and then the third nodes (all of them) (categories->category(all)->products(all) and not in the right order (categories->category->all products for that category) selec...

How to get total result count in paged result views?

Hi, I have a DB table with approx. 100,000 entries. My web app will show paged results of search queries, which may yield between 0 and 100,000 records. When generating the output I want to do two things: Show total nr of results Show paged view, with 50-100 results per page. Obviously I would like to query records for just one pag...

Ruby Rails Nested Records

I'm not sure if what I'm even trying to do is possible but here goes. I have an SQL database with the following tables defined (showing only relevant tables in SQL): CREATE TABLE customers( id integer NOT NULL UNIQUE, name vachar(25) NOT NULL, surname vachar(25) NOT NULL, password vachar(20) NOT NULL, email_address ...

Cannot create SSPI context

Hi All, I am working on a .NET application where I am trying to build the database scripts. While building the project, I am getting an error "Cannot create SSPI context.". This error is shown in the output window (inside VS2008 screen) and the building process failed. Please help on this. SQL Server is configured to work on Windows aut...

how to enforce a database self join (or is there a better way)

I have an employees table in a database, and I want to link an employee to their manager: Employee Table employee_id first_name last_name manager_id If the manager_id is just another row in the same table where the manager has it as their employee, what is the best way to enforce that if I delete an employee it verifies that this ...

SQL Server 2008 CTE And CONTAINSTABLE Statement - Why the error?

I am testing out moving our database from SQL Server 2005 to 2008. We use CTE's for paging. When using full-text CONTAINSTABLE, the CTE will not run and generates an error. Here's my non-working code- WITH results AS ( SELECT ROW_NUMBER() over (ORDER BY GBU.CreateDate DESC ) as rowNum, GBU.UserID, NULL AS DistanceInMi...