sql-server-2005

SELECT and UPDATE table so there is no overlap of Threads

Hi, Say I have the following table: ID|Read ------- 1|true 2|false 3|false 4|false ... and I need to read the smallest ID, that has [Read] == false; plus, update that I have now read it. So if i execute my Stored Procedure dbo.getMinID, it will return ID: 2, and update [Read] -> true. CREATE PROCEDURE [dbo].[getMinID] ( @Quer...

How to get if a string is a number in T-SQL

Hello. Is there an easy way to get if string is an integer number (consists only of digits) in MS SQL 2005? Thank you for your help. ...

cannot connect to local server

i have sql server 2005 installed in my local machine. when i installed it, i was able to connect to the local server which is named "MNTCON016". After restarting the machine, I found out that i was not able to connect to the local server "MNTCON016". it gave me the following error. A network related or instance specified error occured wh...

T SQL Convert a row to a string

Is there a valid way in SQL Server 2005 to read a row of data into a string? For example if my table looked like the following: ID | First Name | Last Name | Color ----------------------------------- 1 | Timmy | Jones | pink 2 | Martha | Fisher | green That I could get back as a result: '1 Timmy Jones pink' '2 Mart...

Pivoting a table in SQL Server 2005 to contain same column multiple times

I need to pivot the following table named tblGameRoleName - Game Role Name VolleyBall Coach Sujatha VolleyBall Player Rajendran VolleyBall Player Juno VolleyBall Player Indira VolleyBall Player Ganesh VolleyBall Player Vasanth Tennis Coach Rajeshkumar Tennis Player Vivek Tennis Player Rubala ...

Querying for a unique value based on the aggregate of another value while grouping on a third value entirely

So I know this problem isn't a new one, but I'm trying to wrap my head around it and understand the best way to deal with scenarios like this. Say I have a hypothetical table 'X' that looks like this: GroupID ID (identity) SomeDateTime -------------------------------------------- 1 1000 1/1/01 1 1001 2/2/02 ...

is there a regex function for Xpath in TSQL

I need to query rows of XML data where a specific element contains more than 1 upper case character. Sounds like a job for RegEx --- but I can't find a reference to such a function in the XPath for SQL Server 2005. I can't create a SQLCLR function on this server, so using .NET is not an option. ...

How to configure SSIS 2005 OLE DB data source component to use sql query from external file?

I am using OLE DB data source component as a part of data flow task, but I would like to keep the sql query in an external file and not embedded in the task itself. Is there an easy way to accomplish this? ...

Why not "Invalid column name XYZ" error in subquery; although column name is not in subquery table?

When I run this query SELECT CustomerId FROM Stocks.dbo.Suppliers It gives me this error. Invalid column name 'CustomerId'. This error is valid as there is no column CustomerId in Suppliers table; but when I use same query in subquery it does not give any error E.g. SELECT * FROM SomeOtherDb.dbo.Customer WHERE CustomerId In( SEL...

SQL Server Date format Issue

I have this query to display records based on date Select * From orders Where CONVERT(VARCHAR(50), Orderdate, 101) = CONVERT(VARCHAR(50),'1/21/2010', 101) Though there are orders for today, the query is failing because the date passed is not 01/21/2010 How can I fix this issue in the query itself as the date passed by the other ...

XML declaration with "FOR XML PATH" in SQL Server 2005

Below is a simplified version of a query that I have already created. The query works fine, but I cannot figure out how to get the XML declaration at the top of the generated XML. I've tried multiple things and searched far and wide on the Google, but alas I cannot seem to find out how to do this ... or even if it is possible. select ...

Can't create table relationship - SQL Server 2005

I am getting an error when trying to create a relationship within two tables in Sql Server 2005. I am attempting to create the relationships using the database diagram feature. I have a Player table and a Message table. I want to create two relationships from the Message table to the Player table. I can successfully create the first rela...

how to get two decimal from divied by sqlserver

select 2/3 how to result 0.67 via sql sever 2005 ...

Views based on views based on etc..

I have this script(dtsx file) on a sql 2005 server (made by some other technician), some stored procedures update tables with data from views. I can see that these views are based on other views, sometimes 4 to 5 layers thick before hitting the database tables. Would you recommend to improve this construction? (when confronted with this...

Slow performance of Reporting Services, very fast in QueryAnalyser

We're using SQL Server 2005 with Reporting Services. We have a number of reports, each containing a relatively simple SQL query - by "relatively" I mean that we do have a few joins, but nothing worse than that. We do not call any stored procedures in our queries - this is not a case of parameter sniffing. When executing one of these re...

How to eliminate superfluous namespace declarations in SQL generated XML?

I'm fine tuning a web app that calls SOAP services backed by SQL stored procedure calls. Typically the stored procs generate XML that becomes part of the SOAP response, and that XML has many superfluous xmlns namespace declarations. In pathological cases this can be 30% or more of the char encoded XML measured in bytes, e.g.: <GetFooRes...

Getting first n numeric characters from a varchar column in SQL

I'm building a hash, using the house number from an address field. What SQL can I use to select only the numeric characters from the front of a varchar field? EX: 12345 South 1st Street I want the 12345. Thanks in advance. ...

Connection error in sql server 2005

hello ! I have a problem,I run application C# and I get a error "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (p...

Is it possible to save and reuse a set of Parameters as a code block in SQL Server Express 2005?

I have several stored procedures that all use the same set of parameters. Is there a way to define and save the parameter list as a reusable block of code? Something like this: CREATE PROCEDURE test Using StoredParameterList AS BEGIN SQL Statement END Is this possible? It would make code maintenance easier if a parameter n...

SQL Server 2005 Connectivity problem from .NET

I'm unable to connect to SQL Server 2005 from .NET. I'm getting the error " A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider...