sql-server

ssrs combining rows into result set

So I have a sql server 2005 query that returns results like so: Address | Doctor ----------------------- 1 Dr A 1 Dr B 1 Dr C 2 NULL 3 NULL 4 Dr D 4 Dr E 5 Dr F What I want is to get the output so that when I render the report I have them grouped together: Dr A Dr B Dr C...

tsql script to find tables not being used by stored procedures, views, functions, etc?

Is there a t-sql script to find out tables that aren't being used in sql server by stored procudures, views, functions, etc. I have a database that has 100s of tables, if not more and before I go dropping tables, I wanted to know if there was a script that could go through each object in the database and tell me if any tables are in use...

Websites that contain useful and reliable scripts for sql server?

Are there any useful and reliable, keyword being reliable here that contain sql server scripts, especially for viewing the statistical usage of the database. I know there are a lot of sql server sites that have scripts, but you never know if they are reliable scripts. ...

Securing a SQL databse account for an ASP.Net site

I am trying to secure a MSSQL database for our .Net website. I wanted to separate the database into different schemas so that we had an schema like 'Account' which had personal information and a schemas like 'Public' that had generic public content data. Each of these schemas would be accessed using different SQL user accounts and they...

Aliases in SQL Server

Are these two statements equivalent? UPDATE Table1 SET Field1=( SELECT Field2 FROM Table2 WHERE Table1.ID=Table2.ID ) FROM Table1 WHERE Field1 is null UPDATE t SET Field1=( SELECT Field2 FROM Table2 WHERE t.ID=Table2.ID ) FROM Table1 t WHERE Field1 is null I'm trying to reduce the amount of aliasing. I feel that adding a...

Can SqlServer be configured to not execute stored procs submitted as strings?

Scenario A: SqlConnection con = new SqlConnection(myConnString); SqlDataAdapter adp = new SqlDataAdapter("EXEC spGetUserInfo 42", con); DataSet ds; adp.Fill(ds); Scenario B: SqlConnection con = new SqlConnection(myConnString); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "spGetUserInfo"; cmd.CommandType ...

Software as a service - Database

If I am building a CRM web application to sell as a membership service, what is the best method to design and deploy the database? Do I have 1 database that houses 100s of records per table or deploy multiple databases for different clients? Is it really an issue to use a single database since I believe sites like Flickr use them? ...

Use each row in one table by joining it to another table

I'd like a query that at its simplest will join 2 tables together with no other express relationship other than each row in what I will call the "pool" table will match to precisely 1 row in my other table. I don't care which row, I just want every row in my primary table to get a single row from the "pool" table and know that each row f...

Maximum Count Range Intersection (in T-SQL)

Let's say I have a table with a bunch of dates, e.g.: declare @tbl table { idx int primary key, startdate datetime, enddate datetime } And I want to find the largest set of rows where startdate and enddate intersect (in the real world, the start date and end date represents start and end times for events, and I need to fin...

what is the maximum data stored on sql server cluster ever?

What do you think is the maximum database size ever stored on sql server cluster? ...

sql 2005 profiler analysis

we have some performance issue with a program, I traced tsql using sql server 2005 profiler and find below result for an INSERT statement, cpu: 0 read: 28 write: 0 duration: 32804 I guess it's because the inserted table has several indexes and it's getting big. is there any other possibilities that I should check? thanks. ...

SQLServer vs StateServer for ASP.NET Session State Performance

I'm studying for a MS certification and one of the practice tests I'm doing has a question where the point of contention is the performance between storing the session in SQL Server as opposed to StateServer. Given the app is running in a web farm, which solution for session state gives the best performance (SQL Server or StateServer) a...

SQL Server 2008 stops responding after webserver inactivity

I've recently setup a couple servers with the intention of moving our websites on to them. One is Windows Web Server 2008 and the other is Windows Server 2008 Standard running Sql Server 2008. The first thing I installed was FogBugz, and everything seemed to install and run smoothly until we stopped using it for a while. Then when tryin...

5 joins? only result from one of them is needed, but order is important?

I am doing left outer join to my table with around 5 different tables and I need result from only one of these 5 tables. Now I know I could use Coalesce to get what I want. However, I was wondering if there is a way to tell SQL to not keep on joining as soon as one left join hits. However, the left outer joins need to occur in the same...

Insert Trigger not working properly

Hi all I have created the following trigger for insert in the deleted user table the corresponding record has to be deleted from the userlogin table. The trigger involves the following statements: CREATE TRIGGER trgInsert_ToDeleteFromUserLogin on DELETEDUSER FOR INSERT AS BEGIN DECLARE @UserName nvarchar(50), @UserType nvarchar(30), ...

Determine file path of database

Hi to all, Is it possible to run a script that gives the directory and files for all databases installed on a server? So for example, instead of launching SQL server management studio and checking properties tab for the database and then checking the database files for the data and log file and then doing this for all databases which ...

C# Linq-to-SQL Trying to recive multiple selects

Hello! I got this SQL code in a SP: (MS SQL 2008) DECLARE @type tinyint SELECT @type = Type FROM Contents WHERE ContentID = @ContentID SELECT [ParentContentID], [Headline], [ShortDescription], [CategoryID], [Type], [State], [DatePublished], [Name] FROM Contents INNER JOIN Users ON Users.ID = Contents.PublishedBy WHERE ...

There must be a way to delete data in SQL Server w/o overloading the log

I need to delete a bunch of data, and don't have the disk space for the log to continue growing. Upon looking into the matter further, it looks like there isn't any way around this, but I thought I'd ask for sure; it's difficult for me to believe that something so simple is impossible. I tried looping, deleting in chunks, and calling s...

Mystery type mismatch while dealing with ASP

Hey everyone, I've never developed in ASP in my life, but a client wants some additional functionality in one of his really terrible ASP programs extended. I've tried to pick up as much as I can in a short period of time, but I'm running into a mystery bug here. When I unit-test this code on my local system, it works fine. On their w...

Is Entity Framework tied to SQL Server ?

What if I want to connect to Oracle, MySQL or even MS Access ? ...