sql-server-2005

How to run a stored procedure report and then send the result into email?

Hi there I am using SQL Server 2005. I have a report that is using stored procedure with just few lines of records and would like to send the whole recordset through an email and sets this into a schedule. This is only an interm solution BTW till we integrate this stored procedure into reporting service + .net app. I am appreciated yo...

Violation of PRIMARY KEY on select statement

I have a table that looks like this: CREATE TABLE [dbo].[SomeTable]( [Guid] [uniqueidentifier] NOT NULL, [Column1] [int] NOT NULL, [Column2] [datetime] NOT NULL, [Column3] [bit] NOT NULL, [Column4] [smallint] NOT NULL, [Column5] [uniqueidentifier] NULL, [Column6] [varchar](100) NULL, [Column7] [datetime] ...

performance tuning with procedure having temp tables

Hi There, i have many queries which needs to be tunned and i was relaying on DTA(datbase engine tuning adviser which comes with sql 2005) to give me some recommendation on indexes. but looks like DTA fails to understand the queries which uses temp tables . is there any way we could get the index recommendation. Thanks for your suggesti...

How to alter length of varchar in composite primary key?

In MSSQL I have a table created like this: CREATE TABLE [mytable] (fkid int NOT NULL, data varchar(255) CONSTRAINT DF_mytable_data DEFAULT '' NOT NULL); ALTER TABLE [mytable] ADD CONSTRAINT PK_mytable_data PRIMARY KEY (fkid, data); Now I want to increase the length of the 'data' column from 255 to 4000. If I just try: ALTER TABLE [...

Design SQL Query for following case

Consider tables Table1 id, name 1 xyz 2 abc 3 pqr Table2 id title 1 Mg1 2 Mg2 3 SG1 Table3 Tb1_id tb2_id count 1 1 3 1 2 3 1 3 4 2 2 1 3 2 2 3 3 2 I want to do query to give result like id title 1 MG1 2 MG2 3 Two or More Ti...

SQL Server 2005 Fulltext Search Problem

Hi all, currently I am trying to get the full text search of the SQL Server 2005 to work. I've got a table where all string columns are populated in a full text catalog. Now I want to search within these columns. E.g. a row in the first column contains "Name123", the second column contains "LegalForm123" The second row in the first c...

How to update two tables in one statement in SQL Server 2005?

I want to update two tables in one go. How do i do that in SQL Server 2005? UPDATE Table1, Table2 SET Table1.LastName = 'DR. XXXXXX' ,Table2.WAprrs = 'start,stop' FROM Table1 T1, Table2 T2 WHERE T1.id = T2.id and T1.id = '010008' ...

sql timezone calculation

I have a table which stores the storecodes and their timezone. Now based on a given local date, I need to know if that date converted to stores local date was a in a weekend or not. Now I already know how to get the weekend part. I am struggling with the conversion. I am actually confused. My table has for example the following two value...

SQL Server Replication by column mapping

Is it possible to use SQL Server's replication service to replicate from table A on a given server to a different schema on table B? ie, Table A ---------- ID int Name varchar(20) Data text Table B ---------- ID int Name varchar(20) Description varchar(10) Replication would copy "Name" from table A to table B for a gi...

SQL recursive CTE query, odd results set SQL Server 2005

I am trying to write a recursive CTE query in SQL Server 2005 but am getting an odd set of results. My table is: PairID ChildID ParentID 900 1 2 901 2 3 902 3 4 This is my CTE Query: WITH TESTER (PairID, ChildID, ParentID, Level...

Outputting long fixed-width records to a flat file using SSIS

Hi everyone, I have to build an SSIS package for work that takes the contents of a table, all columns, and outputs it to a flat file. The problem is, one of the columns is a varchar(5100) and that puts the total row size at about 5200 characters. It seems the flat file connection manager editor won't let me define a fixed-width row be...

Extending MembershipProvider

Scenario: Building an application for companies to enter information into. I need to extend the built-in membership provider in asp.net. My unique situation is that I already have demographic information for each company, but NOT userid's and passwords for a web app. I want to prepopulate the DB with the demographic information, send...

SQL Server 2005 - CTE, retaining values and inserting in datasets

Lets say you have a table as such (SQL SERVER 2005) pairID childID parentID 0 1 2 1 2 3 2 3 4 And you have a CTE that return this dataset: pairID childID parentID level 0 1 2 2 1 2 3 1 2 3 4 0 How do you save the initial child ID so that yo...

How to find if a word has all vowels (SQL Server 2005)

DECLARE @t TABLE(Words VARCHAR(100)) INSERT INTO @t SELECT 'Stack Overflow' UNION ALL SELECT 'EQUATORIAL' SELECT * FROM @t WHERE Words LIKE '%[AEIOU]%' I am getting both as the output Words Stack Overflow EQUATORIAL The desired output being EQUATORIAL Thanks ...

Stored Procedure returning Multiple resultset

Hi One Stored procedure returning multiple result sets and I need only the last result set, How do I achieve this without changing original procedure. am using the last reulst set in further processing in other Stored procedure. ...

SQL Query: Without using Subquery

how can i get all the records from 1st table not present in the 2nd table without using subquery? i would like to use Join... ...

Delphi .NET/SQLDirect 6.1: Adding varbinary data in a JSON object.

Hi, I am making a call to a stored procedure which returns varbinary records which I want to store in a JSON object. When I do the same for other data types I use the following TField properties to extraxt the data from the data set: FStoredProc.FieldByName(ColumnName).AsInteger (or .AsString etc) I thought I would be able to use FStor...

SQL Server 2005 SSIS Data Transfer SQL to Excel Corrupts Excel File

I have an SSIS package that exports data from a table on a SQL Server 2005 database to an Excel Spreadsheet. The spreadsheet in question has 15 sheets, and I am trying to populate values on one of these sheets. I have a template file which I clone to be the target for the export (a simple file system task). This template file is valid, ...

Query on datetime fields with milliseconds gives wrong result in SQL Server

I'm running into an odd bug using datetime fields in SQL Server 2005. The datetime field shows up with millisecond-level accuracy, but it looks like the milliseconds are not always used. Here's my test query: SELECT col1, YEAR(col1) AS yr, MONTH(col1) AS mn, DAY(col1) AS dy FROM mytable WHERE col1 >= '2009-12-31 00:00:00.0' AND col1 <= ...

Repeating Chart in SSRS?

Hi, I'm working on some reports in SSRS 2005. I have a bit of experience of SSRS, but I can't figure out for the life of me how to do this. The report pulls in a data set from a stored procedure. Then I basically want to generate a Pie Chart for each row in the dataset. How on earth can I make the chart control repeat n times? is i...