sql-server-2005

Evaluate in T-SQL

I've got a stored procedure that allows an IN parameter specify what database to use. I then use a pre-decided table in that database for a query. The problem I'm having is concatenating the table name to that database name within my queries. If T-SQL had an evaluate function I could do something like eval(@dbname + 'MyTable') Current...

Re-indexing large table - how screwed am I?

I have a 1 TB, 600m row, table which has a misguided choice of indexed columns, specifically a clustered index on the primary key column which is never used in a select query. I want to remove the clustered index from this row and create it on a number of other rows. Table is currently like this: colA (PK, nvarchar(3)) [clustered i...

Update autoincrement column in SQL server.

I have a need to change ONE PK value in one row of a table of a SQLSERVER 2005 databsae. The PK is currently auto-incrementing. One possibility is to temporarily remove the auto-increment from the key, make the modification, and put it back. The database is in production. Is there a way to safely make this change without taking the DB ...

Using Logic in TSQL

I want to do something like this in TSQL (SQL Server 2005): IF (Column1 = x) { --CTE statement } ELSE { --SQL statement } Any help is appreciated. ...

How to describe Full text search for a client?

I implemented a full text search "searching in tags", using SQL server 2005, I want to describe for the client what i did, what what full text search means by simple examples? My Client is not a programmer but a good internet user. ...

New to SSRS

Hi, I am trying to install and configure SSRS on SQL 2005. When I click "Reporting Services Configuration", I get a message saying "No report servers were found on the specified machine" - Details Invalid namespace. How can I resolve this? Thanks ...

SQL Multiple Parameter Values

What options are available in SQL 2005 to pass in multiple values to store procedures Psuedo codes In C# code List<string> myApplicationList; .... (code to assign values) **Construct parameter list** Call stored procedure [spSelectMaster] with myApplicationList SQL stored procedure CREATE PROCEDURE [Ecn].[spSele...

How to check which locks are held on a table

How can we check which database locks are applied on which rows against a query batch? Any tool that highlights table row level locking in real time? DB: SQL Server 2005 ...

How to choose a columns of a select statement based on conditions?

I have to create an SQL Server 2005 query which checks for the value of one attribute in the table and based on its value, select different sets of columns. How can I do that? for e.g. In table 'car', if the values of 'type' attribute are 1 and 2 when type = 1, i want to execute a select 'query1' with 3 columns. when type = 2, i wan...

sql server 2005 command line install error ADD_LOCAL property already installed

Hi, I have a silent installation of SQL Server 2005 that works great when installing SQL Server on a machine that does not have it already installed. I use the following parameters when I perform the installation: #define SQL_SILENT "/passive /qb" #define SQL_USERNAME "username=MyUserName" #define S...

Sql server 2005 torn page,error 424

Hi all, My Dell pc failed;it was blue screen.I fixed that problem by formatting and reinstalling OS and other software that i have been using.Then I recoved my db designed using sqlserver 2005 and other files using recovery tools ;Easy Recovery 6.0. The problem is : When I try to attach the recovered file(lpdb.mdf),It can not attached.T...

Conditionally branching in SQL based on the type of a variable.

Hi everyone. I'm selecting a value out of a table that can either be an integer or a nvarchar. It's stored as nvarchar. I want to conditionally call a function that will convert this value if it is an integer (that is, if it can be converted into an integer), otherwise I want to select the nvarchar with no conversion. This is hitti...

Merge Select statement and order dynamically?

I have a select statement which will return me 5 values as val1,val3,val5,val2,val4 I have another select statement which is going to return a set of records with one of the column having values from the above set (val1 to val5) Is it possible to sort the second select statement with the result of the first select statement? I mean i...

Running SQL Server 2005 in Windows Safe Mode

My computer has recently crashed and I can only run it in Safe Mode. I need to back up a SQL server 2005 database and transfer it a computer that works. Is there anyway to run SQL server 2005 in Windows Vista Safe Mode? ...

Permission rights for SQL login accessing Database for ASP.Net Application

I always wonder what are the exact access rights and permissions I need to give to a sql login which I use from my asp.net application to access database. The application execute some stored procedures which insert, update and delete data into tables. I do select, delete, update directly on the tables also. Also there are some triggers. ...

Database Replication MSSQL 2000 to 2005

I am trying to replicate a database from SQL server 2000 to 2005 they are located on two different servers both running Windows Server 2003 R2. Im am using SERVER1(SQL2000) as the Transactional publisher and distributor and SERVER2(SQL2005) is the subscriber. I can set up the publication and subscription but when I try to syncronize them...

Union two or more tables, when you don't know the number of tables you are merging

I am working with MS SQL 2005. I have defined a tree structure as: 1 |\ 2 3    /|\ 4 5 6 I have made a SQL-function Subs(id), that gets the id, and returns the subtree table. So, Subs(3) will return 4 rows with 3,4,5,6, while Subs(2) will return one row, with 2. I have a select statement that returns the above Ids (joining this t...

SQL Server database with MASSIVE amount of tables

I've been asked to troubleshoot performance problems in a SQL Server 2005 database. The challenge is not a huge amount of data, but the huge number of tables. There are more than 30,000 tables in a single database. The total data size is about 650 GB. I don't have any control over the application that creates all those tables. The appl...

SQL Server 2005: How to automatically include database name and brackets in queries

Good day, In SQL Server 2005, when I write a new query, I like to drap and drop table and column names from the object explorer. However, when I drag and drop a table, is there a way to automatically include the database name? (example: when I drag and drop the table Table1 in the query designer, I would like to have Database1.dbo.Ta...

Iterate over a rowset, get a field which matches parameter, and then another field from that row

I have a stored procedure which has to get a password from my Users table. I am using a Username as a parameter. What is the best way to get the row where the Username field's contents match the Username parameter, and then the password (as this is the Username/password pair for one user). Cursors are one way to iterate over a rowset b...