sql-server-2008

SQL Server temp DB issue

Hello everyone, I am using SQL Server 2008 on Windows Server 2008. I find the temp DB mdf and temp ldf is very big (about 13G), and it is almost the same size of all other real application database files (mdf+ldf). My questions, What temp DB is used for? Is it normal situation that temp DB is so big? If not, any ways to clean-up temp...

I am trying to get comfortable creating joins with T-sql 2008

I am trying to write this select statement. My select statement consists of a join that returns all of the first and last names of my fictional employees, their department names and I am trying to group the individuals by their respective departments. This is the code I wrote: select e.First_Name,e.Last_Name,Department_Name from EMPL...

updating a sum of one table based on input from another table

Hello, We've the following SQL that we use to calculate total costs. SELECT DailyProduction.CustomerId as CustomerId, SUM(Resource.CostPerUnit * DailyProduction.UnitsToStorage + Resource.CostPerUnit * DailyProduction.UnitsToMarket) AS TotalCost FROM dbo.hgm_ResourceTypes Resource JOIN dbo.hgm_ResourceDailyProduc...

LINQ-to-Entities get rid of sp_executesql

I am trying to optimize my database now using Database Engine Tuning Advisor, and the problem I am facing is that my SQL Profiler trace shows tons of queries performed using sp_executesql - and the advisor fails to process those. It seems like these queries come from LINQ-to-Entities I am using, so just curious if there is any way to mak...

From stored procedure how get max number

Create Procedure [dbo].[spGenerateID] ( @sFieldName NVARCHAR(100), @sTableName NVARCHAR(100) ) AS BEGIN SELECT ISNULL(MAX(ISNULL(@sFieldName, 0)), 0) + 1 FROM @sTableName END In the above procedure I supply the field name and table name and I want the max number of this fi...

creating relationships with sql server 08 express in visual web dev 2010

OK so I have never ever touched asp.net and have absolutly no idea what I am doing. I create database structures via SQL Scripts not GUI enviornments. So I am trying to learn ASP.NET and I have started an MVC Web App project. I have an account table and an address table and an account_addresses_xref table. table: account fields: acco...

BACKUP failed to complete the command BACKUP DATABASE

BACKUP failed to complete the command BACKUP DATABASE ... WITH DIFFERENTIAL. Check the backup application log for detailed messages. I see this message in SQL Server log file viewer. Where is the backup application log? ...

Multipart identifer could not be bound, correlated subquery

This is a contrived example using SQL Server 2008. I'm essentially storing a list of ids in an xml column in a table: temp (bigint id, xml ids) I want to join the table itself to the xml nodes. So far I have: select * from temp x join ( select x.id , ids.id.value('@value', 'bigint') zid from temp t cross apply ids....

How to reload a table without growing the log file?

I have the following scenario which runs every night using SSIS in SQL Server 2008: create a few temp. tables, and import data from an ODBC data source when the imports are complete, drop existing tables, and rename the temp. tables to the same name as the dropped tables What do I need to do in either my SSIS job or SQL Server settin...

View another schemas objects in object explorer . SQL server 2008

I need to see the objects from another schema that I have read permissions from in the object explorer. I can select from them in the query window but I do not see them in the object explorer. ...

ORDER BY with a CASE statement for column with alias

I need a stored procedure which will allow me to return sorted results based on two input parameters: @sortColumnName and @sortDirection. I wrote the following stored procedure, but when I run it, I am getting this error: "Invalid column name 'LastPayCheckDate'." SELECT Name, SUM(Pay), MAX(PayCheckDate) as LastPayCheckDate FROM Employee...

Database Changes Rolled back when rebuilding the .SLN (VS2008)

So, folks. Got an interesting occurrence going on here. I have a windows forms application made in VS2008 which has, up until recently, been connecting to a SQL Server 2008 database. I was able to edit, insert, delete, or select any of the various tables within the database, and the changes were commited -- each time I made a change to ...

Specify data type with column alias in SQL Server 2008

Imagine I have the following SELECT statement in a view (SQL Server 2008): SELECT (SELECT CASE WHEN HISTORY.OUTOFSERV = 'Y' OR HISTORY.OUTOFSERV = 'y' THEN 1 ELSE 0 END) AS OOS FROM HISTORY The column OOS ends up being of type int, but I'd like it to be of type bit. How can I acco...

Passing multiple filtering parameters to a stored Proc

Hi, I am sure the title of my question doesn't make much sense. But here is what I'm trying to achieve. I have table with different stories(columns are StoryID, StoryTitle, StoryDesc, StoryCategory), so each story can belong to a category. for example category1, category2,.... category10. I am in the need of a SP, where i specify the ca...

How do I limit the rowcount in an SSIS data flow task?

I have an Oracle source, and I'm getting the entire table, and it is being copied to a SQL Server 2008 table that looks the same. Just for testing, I would like to only get a subset of the table. In the old DTS packages, under Options on the data transform, I could set a first and last record number, and it would only get that many r...

How to query many to many

I'm trying to do a many to many query on these fields. I'd like to get: 1) all the posts that are in a category 2) all the categories that are in a post 3) all the posts that are in a category that have a specific id posts +-------------+--------------+ | id | int(11) | | title | varchar(255) | | body |...

where to find MyDataBase.BAK file on SQL server 2008 ?

hi where to find MyDataBase.BAK file on SQL server 2008 ? and how i can restore this file to my DataBase ? thank's in advance ...

Problem while running SQL Management Studio 2008

I install the MS SQL Management Studio 2008, the installation was successfull but when i run the Management Studio and connect to any Server (diffrent Servers in diffrent locations) I got following error ***** Ausnahmetext ******* System.TypeLoadException: Der Typ "Microsoft.SqlServer.Management.Sdk.Sfc.ISfcDomainLite" in der Assem...

Can't disable Vardecimal Storage Format

I recently moved a database from a 'SQL Server 2005 SP1' instance to 'SQL Server 2008 SP1' (using detach - attach). I now need to move it back but it fails with the error: The database 'MyDB' cannot be opened because it is version 655. This server supports version 612 and earlier. A downgrade path is not supported. After a bit of resea...

how do we alias a sql server instance name

I have two development teams, that come from different groups. Group A develops against a local default instance of Sql Server 2008 R2; Group B develops against a local named instance of Sql Server 2008 R2. Is there a way to setup an alias such that both groups are coding against the same name. As it stands right now we have a war o...