sql-server-2005

Check whether a table contains rows or not sql server 2005

How to Check whether a table contains rows or not sql server 2005? ...

TSQL INTERSECT Keyword

I have known about the SQL Server 2005/2008 keywords EXCEPT and INTERSECT for some time but have never found a compelling reason to use INTERSECT over the good old UNION keyword. Can anyone explain when or why you would use INTERSECT instead of UNION? ...

Working with an unsigned BIGINT in SQL Server

I'm trying to store and retrieve an unsigned int64 using Microsoft SQL Server (and ultimately using ADO.NET EF), but I'm having some trouble. Since you cannot specify an integer column as unsigned in SQL Server, I tried using binary(8), however that's not working like I expected. The following queries result in an unexpected value (0x0...

SQL Server function to eliminate replicated characters

I wonder if there is an easy and efficient way in SQL Server 2005 to eliminate replicated characters in a string. Like converting 'ABBBCDEEFFFFG' to 'ABCDEFG' It really sucks that SQL Server has such a poor string library and no ready-to-use regexp feature... ...

SQL Server 2005 : Converting varchar value '1.23E-4' to decimal fails

declare @a varchar(40) set @a='1.23e-4' declare @b decimal(27,12) if isnumeric(@a) =1 begin select @b=cast(@a as decimal(27,12)) end else begin select @b=-1 end select @b when exeucting above sql code under SQL 2005 environment I am getting following error. Error converting data type varchar to numeric anyone knows why? ...

At how many returned records should I begin expecting performance problems?

I have a query that I have been tuning for some time but I can't seem to get the execution time down much. In the execution plan everything looks like it is doing what it is supposed to, no large costs associated with any particular part of the query, everything is using index seek where it is supposed to. When I run the same query aga...

TSQL to know database role members

Hi, I am using SQL 2000 and SQL 2005. I want to know which logins have db_owner or db_accessadmin rights to which databases. I can click on users or database roles in every database to see that. Could this be done in an easier way using TSQL? Thanks in advance ...

Passing database name as variable to SQL from C#. Is it possible?

I've 2 tables having exactly same columns. But they are stored in Database1 and Database2 (on same server). Can i pass database name as variable? For example: SELECT [SomeValue] FROM [Database2].[dbo].[Klienci] SELECT [SomeValue] FROM ...

Consequences to setting the db compatibility level to SQL Server 2000

We have a Sql Server 2005 DB. For whatever reason, the compatibility level (e.g. via sp_dbcmptlevel) is set to 80 (which is Sql Server 2000). What are the consequences of that? Is there a performance penalty for my apps because of it? ...

SQL Server Synonyms Performance with Views

If I have two databases and create a linked table (synonym) in one of them to the other one and then wrap that synonym in a view, will there be a performance issue? The reason I want to do this is to have SQLMetal see the synonym and generate a linq entity for it. The database are on the same server. Also if I did this 100+ times, all...

Replication vs Sync Framework vs Service Broker

I've asked about each of these technologies separately, and really haven't found a suitable answer. We have a server in our central office running SQL Server 2005 Enterprise that has several large (large in the sense that DSL is the limiting factor) databases that we need local copies of at each of our locations. We currently have a fe...

passing multiple parameters to sql procedure as a single string variable

From front end(studio 2008) I am passing values to sql procedure as : string a = "hello" + "098765" + "world" + "90.0909" These are 4 different values that I've concatenated into a string a; now i pass this string a to the sql procedure using c# sqlCommand object. Now, how do I retrieve these 4 values in sql procedure as I've created...

@@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT [sql server 2005]

Which should i use to get last inserted record id in sql server 2005? I searched stackoverflow and i found this, http://stackoverflow.com/questions/45651/sql-how-to-get-the-id-of-values-i-just-inserted Comment of the best answer: there are known bugs with SCOPE_IDENTITY() in sql server 2005, not sure about 2008, the OUTPUT clause can...

Cannot see table in Object Explorer, SQL Server 2005/2008

This may be a dumb question. But I just received permissions to read/write to this DB. I see the tables of the DB, except for one. I can select from it, But I cannot see it in the Object Explorer. I restarted my computer, refreshed the object explorer and everything. Is there a restriction on viewing this table? ...

What is SQL Server doing between the time my first record is returned and when my last record is returned?

Say I have a query that returns 10,000 records. When the first record has returned what can I assume about the state of my query? Has it finished and is just returning records from the server to my instance of SSMS? Is the query itself still being executed on the server? What is it that causes the 10,000 records to be slowly ret...

SQL Server 2005 query multiple Access databases?

Is there a way to get SQL Server 2005 to query 3 or more separate Access databases (each returning 1 record) in one SQL statement? ...

SQL Server parallels to Oracle Alter Table Set Column Unused?

Is there a parallel in Microsoft SQL Server (2005, preferably) for the Oracle functionality of setting a column to be unused? For example: ALTER TABLE Person SET UNUSED Nickname; Nothing turns up in searches, so my thought is this feature must be Oracle specific. ...

Notify a C++ application when a change in a SQL Server table is made

I've posted this before but haven't obtained a suitable answer that fits my requirements. I'm looking for a technology to notify a C++ application when a change to a SQL Server table is made. Our middle-tier is C++ and we're not looking to move onto .NET infrastructure which means we can't use SQLDependency, or SQL Notification Servers. ...

SQL Server Recursion Question

I need to create links between pairs of items and rows of item pairs: ItemA ItemB ---------------- 1 2 1 3 4 5 4 6 6 2 7 8 9 2 9 10 11 12 11 13 14 15 Matching on either side of a pair constitutes a link: Link A B --------------- 1 1 2 1 1 3 1 4 5 ...

How to debug stored procedures in sql server 2005

How can I debug stored procedures in SQL server 2005. ...