sql-server

SQL Server 2008 Full Text Index issue

Hello everyone, I am new to SQL Server 2008 Full Text index function. I am learning from this tutorial, http://www.codeproject.com/KB/database/SQLServer2K8FullTextSearh.aspx. I am using SQL Server 2008 Enterprise. In the first step of the tutorial, it is mentioned that I need to "Create a Full-Text Catalog", but I did not find the New ...

SQL Server 2008 disk usage issue

Hello everyone, I heard SQL Server 2008 uses less disk space for the same amount of stuff (i.e. more compact format, and more disk space efficient, I mean storing MDF/LDF file) compared to previous version, like SQL Server 2000. Any document to prove that or describe that feature? I just need a high level learning, do not need too much ...

Bad real-world database schemas

Hello all-knowing co-stackers. Our masters thesis project is creating a database schema analyzer. As a foundation to this, we are working on quantifying bad database design. Our supervisor has tasked us with analyzing a real world schema, of our choosing, such that we can identify some/several design issues. These issues are to be used...

how to rank customers in sql 2008(northwind)

i have been asked to write a query which in should rank customers base on the quantity of orders they have. the main important factor is that if two customers have been ordered the same quantity they should have be in same rank. i want to know the way to handle this query. for this i have began as below: select tble1.customerid, RANK()...

how to return a cell into a variable in sql functions.

i want to define a scaller fucntion which in that im giong to return the result into a variable but i do not know how to do this. CREATE FUNCTION dbo.Funname ( @param int ) RETURNS INT AS declare @returnvar int select @returnvar = select colname from tablename where someconditions = something return(@returnvar) i want to make a funct...

LIKE work-around in SQL (Performance issues)

I've been reading around and found that using LIKE causes a big slowdown in queries. A workmate recommended we use Select Name From mytable a.Name IN (SELECT Name FROM mytable WHERE Name LIKE '%' + ISNULL(@Name, N'') + '%' GROUP BY Name) in lieu of Select Name From mytable a.Name LIKE '%' + ISNULL(...

SQL exeption was unhandled in c#

When I want to debug this code it gives error on objConnection.Open(): sqlExeption was Unhandled and say(A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is con...

query plan shows cost of 54% for an insert when no rows actually involved

In one of my queries there's an insert of data into a temp table. Looking at the query plan, it shows the the actual insert into temp table took 54% (just inserting data into temp table). However, no rows are being inserted into the temp table. Why does the plan show a non zero value when no rows are being inserted? ...

How do I SELECT an un-referenced row from a table and lock it?

Hi there, I have a table of chalets where a chalet is referenced by an account... CHALET ------ int ChaletId PK int Berth ACCOUNT ------- int AccountId PK int ChaletId FK The chalets start off un-referenced. When a user buys a chalet the code needs to find an unreferenced chalet and assign it to a newly created account. I think that...

SQL Query to return child records relative to groupings

I am developing a system to process recurring billing for members. Items to be purchased can be grouped together for a special package rate, or purchased individually for a higher, stand-alone rate. The portion of my database schema that determines the amount to be paid for recurring items consists of the following 4 tables: MEMBER_RECU...

DB Concept needed for record editing and rollback ability

I love the way SO retains the edits to Q/A's and allows us to roll back if need be. I'm looking for a DB structure concept on how to implement something similar to this. Can anyone give any insights? My current solution is to have two tables like so... Table1 ID | Date | UserID . Table2 ID | Table1ID | UserID |...

SQL Query Group By Datetime problem?

I have this SQL query: SELECT DISTINCT [BatchCode] ,SUM([Quantity]) as 'Created' ,[TotalQuantity] ,[Status] ,[Destination] ,[DateCreated] ,[CreatedBy] FROM [FGIS].[dbo].[DropshipPackinglist] GROUP BY BatchCode, TotalQuantity, Status, Destination, CreatedBy, ModifiedBy...

Entity Framework: How to properly handle exceptions that occur due to SQL constraints

Hi all I use Entity Framework to access my SQL data. I have some constraints in the database schema and I wonder how to handle exceptions that are caused by these constraints. As example, I get the following exception in a case where two users try to add an (almost) identical entity to the DB concurrently. System.Data.UpdateException ...

Column and Row grouping in SQL Server Reporting Services 2008

this is the desired result in need to populate as a report. where xx is no of people. i have a table which has fields like : ---------- table1 ---------- id state year(as Quarter) gender so i need to determine the count from id and populate as a report. the year is like 20081,20082..20084(in quarter). i have created a dataset usin...

How to place stored procedure in desired location?

On SQL Server 2008, how can I place my stored procedures in "Stored Procedures" folder of my DB? When I declare it this way: CREATE PROCEDURE mySchema.myProc It goes to: MYSERVER\System Databases\Master\Programmability\Stored procedures folder. How to tell server, to store it in: MYSERVER\System Databases\MYDB\Programmability\Sto...

Alter Colum Datatype from Int to Ntext and vice-versa

Hi Experts, I have a Sql table CREATE TABLE [UserTable] ( [ID] [int] NULL, [Name] [nvarchar](50) NULL, [City] [nvarchar](50) NULL ) ON [PRIMARY] In this table column ID have the Datatype Int, I want to alter the data type of the ID column to Ntext, For that I am using the following Sql Query: ALTER TABLE UserTable ALTER...

error with dataset

I have a typed dataset userProfile which is same as a user table in my data base. I am using a stored procedure which changes a password and return a single row of the same user.But when i am using this procedure in .cs code an sql exception telling [There is no row at position 0.] in public UserRow this[int index] { Line 413: ...

SQL Server 2008 generate script wizard gives me a script that results in "unclosed quotation marks"

Hi, I have an SQL server 2008 database instance on one machine. Now I want to copy this database to another machine. I use the script wizard inside SQL Management Studio to generate a SQl-script with the schema and data. The script-file is rather big (around 17 GB). Then I run the sql-script on the target machine it results in a : Ms...

SQL Server 2008 Stored Proc Performance where Column = NULL

When I execute a certain stored procedure (which selects from a non-indexed view) with a non-null parameter, it's lightning fast at about 10ms. When I execute it with a NULL parameter (resulting in a FKColumn = NULL query) it's much slower at about 1200ms. I've executed it with the actual execution plan and it appears the most costly...

SQL Server 2008: INSERT if not exits, maintain unique column

I'm using SQL Server 2008. I've got a column NVARCHAR(MAX) in a table which I want to make sure is unique. The table has 600,000 records and grows every day by 50,000 records. Currently before adding an item to the table I check if it exists in the table and if not I insert it. IF NOT EXISTS (SELECT * FROM Softs Where Title = 'exampl...