sql-server

Best way to find free space in sql server databases?

I want to be able to find out how much space is left in my database files so that I can know when to increase the space so it doesn't do it when the application is running hard out. I would prefer to be able to script this so I can run it across multiple databases ion a regular basis. I have SQL Server 2000 and SQL Server 2005 database...

SQL server 2008 features/benefits?

Duplicate of: known and “unknown” incompatibilities between sql 2005 and 2008? SQL Server 2005 vs SQL Server 2008 [closed] Advantages of MS SQL Server 2008 over MS SQL Server 2005? And many more. Hi I have been using SQL server 2000 for a few years but now have access to SQL server 2008 for development. Apart from the obvious th...

Variable Assignment in T-SQL

In the end of my function, I have the statement: RETURN @Result What I want to do is something like this: IF (@Result = '') BEGIN @Result = 'Unknown' END RETURN @Result The above does not work though. ...

How to Suppress the SELECT Output of a Stored Procedure called from another Stored Procedure in SQL Server?

I'm not talking about doing a "SET NOCOUNT OFF". But I have a stored procedure which I use to insert some data into some tables. This procedure creates a xml response string, well let me give you an example: CREATE PROCEDURE [dbo].[insertSomeData] (@myParam int) AS DECLARE @reply varchar(2048) ... Do a bunch of inserts/updates... SE...

Access vs SqlServer for a Simple Database

I am currently developing a very simple database that tracks people and the company certifications they hold. This db will need to store letters of certification as PDF files. I was asked to develop this in MS Access, but I think it would be better to build it in SQLServer and use Windows Forms to build the interface. This app will need...

T-SQL Process Design and Execution Plan (UDF Parameter Sniffing?)

On SQL Server 2005, I have a complex multi-level allocation process which looks like this (pseudo-SQL): FOR EACH @LVL_NUM < @MAX_LVL: INSERT INTO ALLOCS SELECT 'OUT', * FROM BALANCES(@LVL_NUM) INNER JOIN ALLOCN_SUMRY(@LVL_NUM) INSERT INTO ALLOCS SELECT 'IN', * FROM BALANCES(@LVL_NUM) INNER JOIN ALLOCNS(@LVL_NUM) INNER JOIN ALLOCN_SUMRY...

Assistance on a SQL Query - The multi-part identifier could not be bound

I'm trying to do a sub-select and Inner Join in the same query, with little success. The query, as it stands is below, and returning the error The multi-part identifier "Company.LocalityId" could not be bound. UPDATE Company SET Company.BusinessRegionId = b.Id FROM ( SELECT Id FROM BusinessRegio...

How to clean this Sql data up?

Hi folks, this is a follow on question to a previously asked question. I have the following data in a single db table. Name LeftId RightId ------------------------------------------ Cat 1 Cat 1 Dog 2 Dog 2 Dog ...

How to convert this t-sql script?

I am unfamiliar with Oracle and i need to have equivalent of my script for Oracle. Script: SELECT COL_NAME(parent_object_id, parent_column_id) AS ForigneKeyField, COL_NAME(referenced_object_id, referenced_column_id) AS PrimaryKeyField, OBJECT_NAME(referenced_object_id) AS PrimaryTable FROM sys.foreign_key_columns W...

i want to refine the results obtained from a search

I am using sql server 2000 and asp.net with c# for making a search engine and i want to refine the results obtained from a search without making server connection again and again due to speed factor how can i make my search fast?..............how can i make sql server connection lesser?... ...

How can I transform a table with 1 row with varchar columns into a column?

Hi, In SQL server How can I transform 1 row with varchar columns into a column? I think I need to use Pivot but I can't find an example without agregators this is the situation I have: create table #tmp ( ac varchar(100), bc varchar(100), cc varchar(100)) insert into #tmp (ac,bc,cc) Values ('test1','test2','test3') insert into #tmp Va...

Old data stored in database file

How can I ensure that all data that I've erase from the db tables, is no longer stored in the mdb files (and others) on the hard disk? Here's my situation: My client used to store non-encrypted credit card data, in their database (SQL Server). Thanks to PCI requirements, they now encrypt all that data... However, the mdb file still has ...

Can SQL Sub-query return two/more values but still compare against one of them?

I have this query: SELECT Items.Name, tblBooks.AuthorLastName, tblBooks.AuthorFirstName FROM Items WHERE Items.ProductCode IN ( SELECT TOP 10 Recommended.ProductCode FROM Recommended INNER JOIN Stock ON Recomended.ProductCode = Stock.ProductCode AND Stock.StatusCode = 1 WHERE (Recommended.Type = 'TOPICAL') ORDER BY CHECKSUM(NEWID()));...

Linking Users to Login after restoring a SQL Server 2005 database

I wish to move a database between two servers, I have backed the database up from the first server and done a database restore on the 2nd server, so far so good. However our application make use of a lot of database users that are defined in the database, these have to be linked to logins that are defined in the master database. The se...

SSRS: repeat tablix left-most row group value on each row

Hi folks, I have a tablix in an SSRS 2008 report. It has two-level row groupings, and I'd like the value for the left-most grouping to continue to be displayed on each row. Eg, I get this: group1 subgroup1 500.00 subgroup2 250.00 ... but I'd prefer... group1 subgroup1 500.00 group1 subgroup2 500.00 I can't seem to ...

Transforming OLTP Relational Database to Data Warehousing Model

What are the common design approaches taken in loading data from a typical Entity-Relationship OLTP database model into a Kimball star schema Data Warehouse/Marts model? Do you use a staging area to perform the transformation and then load into the warehouse? How do you link data between the warehouse and the OLTP database? Where/How d...

Simulating MySql's password() encryption using .NET or MS SQL

Hi guys, I'm updating an old ASP/MySql webapp to ASP.NET/MS SQL. We would like to keep the logins from the old website working in the new app. Unfortunately the passwords were stored in the MySql DB using MySql's password() function. Is it possible to simulate MySql's password() function in either .NET or MS SQL? Any help/links ...

SQL Script to alter ALL Foreign Keys to add ON DELETE CASCADE

I have a SQL 2005 database with approx 250 tables. I want to temporarily enable ON DELETE CASCADE to all of the Foreign Keys so that I can do a bulk delete easily. I then want to turn off ON DELETE CASCADE on all Foreign Keys. The only way I know of doing this, is to use Management Studio to generate a full database create script, do ...

SQL view data not updating properly

I have two tables (Knicks and Knacks) and a view that joins the two tables (PaddyWhacks). The tables have the following fields: Knicks.key, Knicks.data1 Knacks.fkey, Knacks.data2 So the view contains: PaddyWhacks.key, PaddyWhacks.data1, PaddyWhacks.data2 I'm using LINQ to SQL to retrieve the full view as IQueryable and everything...

How to load huge (but simple) hierarchical XML file into an SQL table

I have a very large (2.5GB, 55 million node) XML file with the following format: <TopNode> <Item id = "Something"> <Link>A link</Link> <Link>Another link</Link> <Link>One More Link</Link> </Item> <Item id = "Something else"> <Link>Some link</Link> <Link>You get the idea</Link> ...