sql-server-2005

Dynamic Aliases in the SQL statement

I want to display Alias name based on the value of some other column name in the query in SQL Server. For e.g. SELECT P.Amount AS (CASE P.Type WHEN 'Individual' THEN 'Salary' ELSE 'Profit' END) FROM Person P I know the above is not right, but something like this will help. ...

Report with sub-report not generating in Reporting Services 2005

This is my first attempt at employing sub reports and my overall experience with reporting services is minimal (edits to existing reports, creation of some basic reports). I have added a sub report to a an existing report. The sub report returns in about 1 second when tested separately. The query that powers it returns in less than a s...

how to connect to another sql server database(server pc) in local area network

hi to all, i m creating an application, inwhich client has to acces a database stored in a remote location connnected through a live ip. how can i connect simply with a database server placed in LAN. both using sql server 2005 express edition. please refer me or help me on this ...

How to change matched element text with XQuery?

Hi, I'm trying to piece together all the examples I've seen for finding elements and modifying them, but I haven't come up with something that works yet. I created an example below of what I have so far, which I'm running in SQL Server 2005. I'm trying to change the ItemID 4 to 999: DECLARE @x XML SELECT @x = ' <ValueCollection> <It...

Updating a Field based on Values in Two Other Fields

I have a database table containing fields RACE, ETHNICITY and ETH. I need to evaluate RACE and ETHNICITY fields and populate ETH using a series of cases: if Race = W and Ethncity = 1 then ETH = Caucasian etc. Can someone advise me on the best way to structure a stored procedure to accomplish this? ...

Server Name not valid in Connect to Server: Reporting Services

I'm trying to step through the Data-Driven Report Subscription setup, but I can't get past Step 2 of Part 2. I get no options for Server name other than "browse", which only turns up two instances on the local network. I tried the alias I use when connecting to the Database Engine (via the SQL Server Configuration Manager), but won't w...

Find in Files command in SQL Server Management Studio

Is there way to use the "Find in Files" command for searching all of the stored procedures and views for a particular database in SQL Server 2005 Management Studio? Edit I want to search all of the stored procedures in database X for string Y. ...

Can I set a default schema for within a stored procedure?

I'm working on the next update for StackQL. One thing I want to do is have the ability to query over several releases. So when I loaded the October data, for example, I didn't delete the old September database. It's still out there. In fact, you can even still query it by including the database name like this: select top 10 * from...

Any other way to make the query shorter?

select A.regYear, A.regMonth, isnull(A.regCount,0), isnull(B.regCount,0), isnull(C.regCount,0), isnull(D.regCount,0), isnull(E.regCount,0), isnull(F.regCount,0), isnull(G.regCount,0),isnull(H.regCount,0),isnull(I.regCount,0),isnull(J.regCount,0), isnull(K.regCount,0),isnull(L.regCount,0),isnull(M.regCount,0),isnull(N.regCount,0), isnull(...

What is the best way to create an enhanced Data Dictionary?

Without going into specifics...I have a large SQlServer 2005 database with umpteen stored-procedures. I have multiple applications from WinForm apps to WebServices all of which use this DB. My simple objective now is to create a meta-database...a prospective data-dictionary where I can maintain details of which specific app. file uses w...

creating sql diagram

I installed SQL Server 2005, and I want to create a database but I can't. When I right click on the Database Diagrams folder for my database in SQL Server Management Studio 2005, I don't see any choice for creating database diagram. I see two things: Working With sql server 2000 Diagrams Refresh ...

SQL Server : How to get rownumber for each common set of values?

Hi, Say my table is like this... ` Tenancy Number Tenant Number Tenant 1 1 John 1 2 Jane 1 3 Pete 2 56 Fred 2 78 Jackie How can I select the rownumber based on grouping by...

How to calculate age (in years) based on Date of Birth and getDate()

Hi I have a table listing people along with their date of birth (currently a nvarchar(25)) How can I convert that to a date, and then calculate their age in years? My data looks as follows ID Name DOB 1 John 1992-01-09 00:00:00 2 Sally 1959-05-20 00:00:00 I would like to see: ID Name AGE DOB 1 John 17 ...

Did sql server 2005 sp3 stop the SQL service

I need to install SQL server 2005 sp3. I need to know before if the installation need a reboot and if the installation will stop my SQL service. I got over 300 database on my server. thanks. ...

What are the Best Practices to follow while creating a data-dictionary?

I have large and complex SQL Server 2005 DB used by multiple applications. I want to create a data-dictionary for maintaining not only my DB objects but also cross-reference them against applications that use a specific object. For example, if a stored procedure is used by 15 diffrent applications I want to record that additional data t...

SQL query against hardware. Possible?

I need to query the Total Physical Memory, Available Physical Memory and Total Commit Charge of the server. Basically values circled in the picture. Is it possible using SQL Server 2005? ...

Summarize Data for Report using T-SQL Case Statement

I want to create a simple summary report in Reporting Services using age, account and age group as follows: SELECT AGE,COUNT(ACCOUNT)AS TOTALCASES, 'AGEGRP' =CASE WHEN AGE <=5 THEN 'AGE 0 TO 5' WHEN AGE >=6 THEN 'AGE 6 AND OLDER' END FROM MAIN GROUP BY 'AGEGRP' When I run this in SQL Ser...

How to prevent items from going to another page in Reporting Services 2005

I currently have the following problem : i have two matrices in the same report, but the second keep going to a second page. In fact, at anytime, I would like all my documents to fit on one page only. The use of pages in html is just a pain, as it is in excel format, by the way. My question can thus also be rephrased as this : how to...

sql server 2005 delete all table data in a set [DB].[audit].[tables]

So I have a database with around 100 audit tables and I want to empty them out preferably in 1 sql query. The database has 2 sets of tables [audit] and [dbo]. I'm not even sure what I should be calling these groups of tables so finding any kind of results from google is proving difficult. Any suggestions? ...

Determine the hierarchy of records in a SQL database

I've got a problem I was wondering if there's an elegant solution to. It is a real business problem and not a class assignment! I have a table with thousands of records, some of which are groups related to each other. The database is SQL 2005. ID is the primary key. If the record replaced an earlier record, the ID of that record is i...