sql-server

How to calculate percentage with a SQL statement

I have a SQL Server table that contains users & their grades. For simplicity's sake, lets just say there are 2 columns - name & grade. So a typical row would be Name: "John Doe", Grade:"A". I'm looking for one SQL statement that will find the percentages of all possible answers. (A, B, C, etc...) Also, is there a way to do this without ...

Execute a SProc from within a Sproc (using params passed in)

Hi all, Does anyone know of a way to execute a stored procedure from within a stored procudure using some of the params passed in from the original procedure. i.e. if i pass in params @id, @event date, @ log into sproc 1 then sproc 1 will do it's own stuff and pass in @log and @event_date to sproc 2. Thanks! ...

Putting a full-text search index on a view with a function

Hello, I'm using SQL Server 2008 and I have a view that looks like this: select ID, dbo.functionname(ID) from tablename I'm trying to put a full-text index on this, but it doesn't seem to have a unique index that I can go off of. The tablename.ID is the unique identifier. I tried creating an index on it, but it says it cannot schema ...

Debugging SQL Server 2005 Stored Procedures

I am using VS 2008 and trying to step into a stored procedure on a SQL Server 2005 database. I bring up Server Explorer, double-click on the procedure. It comes up in the text window. I set a break point in it, right click and select "Step into stored procedure". It comes back with "canceled by user". MSVSCOM.exe is running on the SQL Se...

Can I use stored procedures (sprocs) to populate my full text index?

I'm using SQL Server 2008 and I would like to use a sproc to tell the database to populate a full-text index. If available, I'd like to know what the sprocs are for the following actions: adding an entry into the index removing an entry into the index full populate ...

How do I get around the Sum(First(...)) not allowed limitation is SSRS2005

The problem that I have is SQL Server Reporting Services does not like Sum(First()) notation. It will only allow either Sum() or First(). The Context I am creating a reconciliation report. ie. what sock we had a the start of a period, what was ordered and what stock we had at the end. Dataset returns something like Type,Product,Cust...

Add "Select top 1000" command to toolbar in SSMS

I am using SQL server management studio (2008) quite a lot these days. If it had a "Select top 1000" command in the toolbar,(or a shortcut key) it would make my life a lot easier. Is there any way i can do it. I tried looking in the customize dialog, but cant find that command there. ...

How to change mm/dd/yyyy to desired format

hi guys, I have date in format mm/dd/yy.For eg:4/1/2009 means April 1 2009.I want to get format as April 1,2009 in sql.Can anybody help? ...

Is managed code is the only way to use SMO in c++???

I have to work with SQLSERVER SMO in C++. Is Managed code is the only way to work with SQLSERVER SMO in C++ ? I have tried many ways.. but I found that using managed code is the only option. Are there other ways? ...

Size of a single Record ? SQL

I have a scenario where every user has been allocated 2 MB of database space. Now I have to show Percenatge usage of their allocated space, to do so I need to know the size of single record in the Table. I have tried to use sp_spaceused and even wrote a custom procedure making use of datalength .. but they show vast difference in their ...

Validate if a column has a null value

Which SQL would be faster to validate if a particular column has a null value or not, why? 1) SELECT * FROM TABLE1 WHERE COL1 IS NULL Execute this query and then check if you are able to read any records. If yes there are null values. 2) SELECT COUNT(COL1) FROM TABLE1 WHERE COL1 IS NULL Read the count which is returned to determine i...

How can I find why some classic asp pages randomly take a real long time to execute ?

I'm working on a rather large classic asp / SQL Server application. A new version was rolled out a few months ago with a lot of new features, and I must have a very nasty bug somewhere : some very basic pages randomly take a very long time to execute. A few clues : It isn't the database : when I run the query profiler, it doesn't det...

Is it ok to load .net dlls into SQL Server as UNSAFE?

When creating a SQL Server CLR stored procedure, I noticed that I couldn't reference anything in the .net framework as I would normally. After some reading around, I realised that assemblies needed to be loaded into the database first. Therefore, I loaded in the ones I need but due to P/Invoke had to use the UNSAFE permission set. I...

Why doesn't SQL Server come preinstalled with .net Framework for CLR Integration?

If I want to reference something in the .net framework for use in my CLR stored proc, for example, I have to first load it into the Sql server database. Why isn't it preinstalled? Is it performance related or for security issues or what else? thanks. ...

Cannot access WSS 3.0 sites after movind Content and Config DBs

Problem: No access to internal sites after new Instance of SQL was installed on MS SQL Server Description: I've got a WSS 3.0 installed on the W2K3 Sever. Originally, there was only one Instance of MS SQL (MSDE) for Backupexec (bkupexec). Later, we installed WSS 3.0 and instead of installing the new instance of SQL we installed on the...

How to count number of same data in a column

Hi all, I have a table: Id Catg 1 cat01 2 cat01 3 cat01 1 cat02 2 cat02 now I want to detect number of occurance of catg01 and catg02,like in this ex, catg01 is 3 times and catg02 is 2 times,I want to count that through LINQ/ simple db query. Pls note: cant use Where clause and hardcode Catg01/catg 02,as there can n number ...

Why 'No math function In Where Clause' in MS SQL?

Most of SQL queries have no math operation on where clause. What is wrong having them on 'where clause'? Is there any performance issue? Eg: SELECT * FROM Employee WHERE Salary*3 = 5000 ...

Is it safe to drop and then create the constraints in the database

Hi All, I am a bit confused and need your help. I have a database that has more than 150 tables. I have several fields which should support Unicode but right now they dont and therefore I want to change the column datatype to ntext and nvarchar in this process I have to drop the constraints and then create them again. Is it safe...

Performance overhead of adding a BLOB field to a table

I am trying to decide between two possible implementations and am eager to choose the best one :) I need to add an optional BLOB field to a table which currently only has 3 simple fields. It is predicted that the new field will be used in fewer than 10%, maybe even less than 5% of cases so it will be null for most rows - in fact most of...

Need help with Sql Server Full Text Search problem.

Hi folks, I have a Full Text Catalog on single table, with three fields defined :- TABLE: Animals Fields: Name, Breed, LatinName. Now, the Catalog seems to be working perfectly. eg. CREATE FUNCTION AnimalSearch ( @Name NVARCHAR(200) ) RETURNS TABLE AS RETURN ( SELECT KEY_TBL.[Key] as Name, KEY_TBL.RANK as Relevan...