sql-server

How to check for the existence of a DB?

Hello all, I am wondering if there is an elegant way to check for the existence of a DB? In brief, how do test the connection of a db connection string? Thanks ...

SQL Server: What is the difference between Index Rebuilding and Index Reorganizing?

Please, can anyone explain me what is the difference between Index Rebuilding and Index Reorganizing? Thanks in Advance ...

SQL Server query to find all current database names

I need a SQL query to find the names of existing databases. ...

SQL Server 2005 Restore Hanging

I have a database showing up in SQL Enterprise Manager as "(Restoring...)" If i do SP_WHO there is no restore process. The disk and CPU activity on the server is very low I think it is not restoring at all. How can I get rid of this? I've tried renaming the underlying MDF file, but even when I do "NET STOP MSSQLSERVER" it tells me t...

Why hasn't SQL Server made a WHERE clause mandatory by default?

It seems like a no brainer to me. I've heard countless stories about people forgetting the WHERE clause in an UPDATE or DELETE and trashing an entire table. I know that careless people shouldn't be issuing queries directly and all that... and that there are legitimate cases where you want to affect all rows, but wouldn't it make sense to...

Can't connect to SQL Server 2005

Hey all, I just installed SQL Server 2005 on my machine and now I am trying to connect to it via SQuirrel SQL, but I am unfortunately running into problems. When installing SQL Server 2005 I chose mixed mode for authentication and I have set up a new user account with which I am trying to connect. I also have installed the Microsoft SQ...

microsoft certifications

Hi Am thinking of getting certified in MCTS and MCPD for ASP.Net and SQL Server (Developer). My question is since Visual Studio 2010, NET Framework 4.0, SQL Server 2008 R2 would probably get released late 2009 or early 2010, should I just wait and take tests for the new versions. Am still planning to study ASP.Net 3.5 and SQL Server 2...

charindex in SQL doesn't give the desired result

I have a string which is a output from a function eg: "1,3,16,..,..". I used the following sql query and ran it in the query builder in VS and it didn't give me any syntax errors. SELECT ItemID, Name, RelDate, Price, Status FROM item_k WHERE (ItemID = cast(charindex(',',@itemIDs) as int)) I gave 3,16 as the @itemID parameter values, b...

Determining application issue, database issue, or hardware issue?

I have a web application, backed by a SQL Server database, which was working fine till yesterday. Now I have performance issues with that application. How do I know whether it is an application issue or database issue or hardware issue? Can anyone help guide me through a step by step procedure of basic troubleshooting to find out whethe...

Is there any way to use SMO in c++ other than Managed Code?

Hi Is there any way to use SQLSERVER SMO(sqlserver management Objects) in c++ other than Managed Code? Help me in this regard... I sincerely request dont give the comment as duplicate still i am not getting Clear answer ...

Getting repetitive column names by adding a prefix to the repeated column name in SQL Server 2005

How can I write a stored procedure in SQL Server 2005 so that i can display the repeated column names by having a prefix added to it? Example: If I have 'Others' as the column name belonging to a multiple categories mapped to another table having columns as 'MyColumn','YourColumn'. I need to join these two tables so that my output shoul...

Why does SQL choose an incorrect index in my case?

I have a table with two indices; one is a multi-column clustered index, on a 3 columns: ( symbolid int16, bartime int32, typeid int8 ) The second is non clustered on ( bartime int16 ) The select statement i'm trying to run is: SELECT symbolID, vTrdBuy FROM mvTrdHidUhd WHERE typeID = 1 AND barDateTime...

How to write a condition in SQL using the COUNT value

Hi iam having two tables and i need to insert the values into a temp table according to the count as IF(@COUNT>1) BEGIN insert into #temp_cols SELECT M.ID_PK, substring(M.NAME,1,1)+'_'+ N.NAME FROM TEST_TABLE1 M WITH (NOLOCK) LEFT JOIN TEST_TABLE2 N ON M.ID_PK=N.ID_FK END ELSE BEGIN insert into #temp_cols SELECT M.ID_PK, N...

Change Notification with Sql Server 2008

I have an application that consists of a database and several services. One of these services adds information to the database (triggered by a user). Another service periodically queries the databases for changes and uses the new data as input for processing. Until now I used a configurable timer that queries the database every 30 sec...

Validate DateTime String in SQL Server 2005

Hi, I require a SQL script to validate a VARCHAR field in a table in a SQL Server 2005 database that contains DateTime values, in the format DD/MM/YYYY, or NULL values. I would like to identify all invalid dates. Can anyone suggest a method? UPDATE The answer has to make use of T-SQL; for performance reasons, I can't make use of SQ...

Descending sort order indexes

The Database Engine Tuning Advisor has finally given up the ghost and can't help me any more, so I'm having to learn a little bit more about indexes (shouldn't it be indices?). I think I'm more or less there. I know when to use composite indexes, what to include with my indexes, the difference between clustered and non-clustered indexe...

Backing up SQL Database for Reports

Hi all! I'm looking for some help/suggestions for backing up two large databases to one server dedicated to reports. The situation is; My company has two databases for its internal website. One for the UK and one for Europe. Both are mirrored for DR. I have a server based in Europe which is dedicated to Microsoft Reporting Services, w...

'SELECT *' from inner joined tables

How do you select all fields of two joined tables, without having conflicts with the common field? Suppose I have two tables, Products and Services. I would like to make a query like this: SELECT Products.*, Services.* FROM Products INNER JOIN Services ON Products.IdService = Services.IdService The problem with this query is that I...

SSRS: How to count true rows

I have a report with a dataset that has a column with booleans. In the table footer I want to display x / y where x is how many rows that were true and y is how many rows there was total. Currently I have this: =Count(Fields!Transfered.Value).ToString() + " / " + CountRows().ToString() But the first becomes same as the last part. I t...

Can you recommend a Sql Server 2008 book for developers that only addresses the new features?

I am looking for a book that only addresses the new development features of Sql Server 2008. I had read "A First Look at Sql Server 2005 for Developers" years ago but cannot find an equivalent book. ...