sql-server-2005

Exporting XML in SQL Server Stored Procedure

Hi everyone, I've written a stored procedure on SQL Server to return an xml that then is shown on a Web Service, and is caught by a LineChart in Flex to show its values. The problem is I need to show different values for each period(I have three different periods: Current, 6 month, 1 year) and it's getting hard for me to generate the x...

How to display all but first table row?

Is it possible to display all but first row from a table in sql server 2005? I have this data: --------------------------------- | ID | Name | --------------------------------- | 1 | John Smith | | 2 | John Doe | | 3 | John Thatcher | --------------------------------- In ...

Defragmenting SQL indexes

I have been trying to defrag indexes in SQL Server 2005 and nothing seems to work. I have created multiple Maintenance Plans using the wizard but the job always fails. I have run the script from this site, which is originally from Microsoft: http://blog.sqlauthority.com/2008/03/04/sql-server-2005-a-simple-way-to-defragment-all-indexes...

sql script to creat a new database

I have following script. I dont know how to create new database in sql server 2005. I run following scirpt, and it create tables under model instead of seperate databse. it look massy. how can i create seperate databse. I am copy some script here for your adive and course of action. -----------------------------------------------------...

SQL Server 2005 - Working with IDENTITY column

Hi, I am working on SQL Server 2005 tables. Here I need to add a column named ‘ID’ as ‘IDENTITY’ column (With starting and incrementing values as 1, 1). Now my problem is that these tables already have thousands of records. So could you please suggest the best and easy way to perform this job? Many Thanks, Regards. Anusha. ...

challenging SQL grouping

I have a query: select event_type, department_name, effective_time, row_number() OVER (PARTITION BY event_type,department_name ORDER BY effective_time) row from a order by effective_time It returns a row set: event_type department_name effective_time 3 A 02/10/09 13:12:00 3 B 02/10/09 15:44:00 3 B 02/10/09 20:...

SQL Server 2005 - Passing 2-Dimensional Array to Stored Procedure

Hi, I am working on SQL Server 2005. Here I need to pass an array (2 dimensional, E.g: Emp No, Emp Name ) having multiple records from my ASP.NET application to a Stored Procedure. Would you please let me know if there is a way to do it? Many Thanks, Regards. Anusha. ...

Issues with building SQL strings

Why won't this piece of code work for me? It gives the error Must declare the scalar variable "@y". DECLARE @y int DECLARE @dbname VARCHAR(50) SET @y = -1 SET @dbname = 'SomeDb.dbo.' SET @sql = 'SELECT @y=1 from ' + @dbname + 'Respondent' exec(@sql) ...

VS2008 not working with SQL Server 2008 Express ???

Hi, I've both VS2008 and SQL Server 2008 Express installed in my computer. When I try create a new DB or attach an existing one, I get the following error message:"This version of server is not supported - Only versions up to 2005 are supported." From that, I'd like to know: Is it possible that VS2008 with SP1 be not able to support...

SQL Server: How to get all child records given a parent id in a self referencing table

Hi I have a which references itself and I need to be able to select the parent and all it's child records from a given parent Id. My table is as follows: ID | ParentID | Name ----------------------- 1 NULL A 2 1 B-1 3 1 B-2 4 2 C-1 5 2 C-2 So ...

SQL Server 2005 Security

Here is the scenario. I have a SQL Server 2005 production database/server. It currently has developers and supporters who can connect to it. I need to create a security module that gives developers read-only access to all areas of the database. This means that a developer should be able to view all objects as well as scheduled activities...

Row convert to column in sql server 2005?

Hi, My table value is Esino ym workeddays name 1 200906 25 a 1 200907 24 a 1 200908 27 a 2 200906 22 b 2 200907 25.... b I nedd out output is Esino ym1 ym2 ym3 w1 w2 w3 name 1 ...

Selecting records during recursive stored procedure

I've got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that's retrieved by a (rather large) series of queries...but I'm attempting to speed things up by using a recursive stored procedure. (As I understanding, using CT...

selecting one value out of an xml column

I have a particularly troublesome xml column to query data from. The schema is fixed by the Quebec Ministry of Revenue so "it is what it is" The important part of the query looks like this: with XMLNAMESPACES(default 'http://www.mrq.gouv.qc.ca/T5') select xmldata.value('(//Groupe02/*/Montants/B_PrestREER_FERR_RPDB)[1]', 'decimal(16,2)...

IF/ELSE Stored Procedure

Hi, Can anyone please point out what im doing wrong with this Stored Procedure please. I cant get it to compile and my software isnt giving any useful clues as to what is wrong with it. CREATE PROCEDURE web.createSubscriptions ( @Member_Id BIGINT, @Trans_type VARCHAR(100), @Payment_Status VARCHAR(100), @Payment_Date DATE...

Performance of Sql subqueries\functions

Hi SO, I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have multiple services associated with it. Within my trigger, I am writing a Query that returns a client's id based on certain criteria....

Testing a Data Pump

I have recently created a DataPump for connecting 2 SQL Servers together but it isn't working. Is there any way to test that the pump is working properly as I wish to eliminate from the list of possible things that may not be working? ...

issues with font displaying

Hi, I'm having issues with font displaying in my report. The report has a header and 2 table in it. I set the font in the header and both 2 table to FontStyle-Normal, FontFamily-Times New Roman, FontSize- 8.5pt for Header, 6pt in one table, 6pt and 5.5pt in the other table. FontWeight- Normal The report font settings looked correct ...

SQL INSERT but avoid duplicates

I want to do some quick inserts but avoid duplicates into a Table. For argument's sake lets call it MarketPrices, I've been experimenting with two ways of doing it but not sure how to benchmark which will be faster. INSERT INTO MarketPrices (SecurityCode, BuyPrice, SellPrice, IsMarketOpen) SELECT @SecurityCode, @BuyPrice, @SellPrice, @...

Raising errors in After Triggers Sql Server 2005

If I raise an error in an AFTER UPDATE trigger in Sql Server 2005, will that cause the update which caused the trigger to be fired to roll back, even if the statement was not executed within a transaction? Thanks. ...