Making Things Easier

Jan 14, 2008

Good afternoon,

I've here a shell plugin and it's compiling fine and can be viewed in BI Dev Studio when choosing the DM technique using the proper wizard.

I also have here a K-Means implementation that estimates the number of clusters using a statistical semi-empiric index (the PBM index).

This implementation is done in C# and works fine. But it has to receive all the data of the database (all variables for each row) in order to do the proper vectorial calculations in a CSR (Compact Sparse Rows) way.

Besides, as you know, K-Means needs all the data at once because of the clusters mean (centroid) calculation.

So, I have some questions:

1) Where to place the call to the K-Means implementation in the shell passing as argument an object holding all the data ?


2) After this call, with the data clustered, what other objects must be modified in order to use Microsoft Cluster Viewer ?


3) I will need to create a new column or a new table on the database to specify which data belongs to which cluster. Can I open an ADO connection as I normally do in other programs from inside the plugin or is there another (easier/better) way to do so ?

Thanks a lot once more.

Best regards,

-Renan Souza

View 1 Replies


ADVERTISEMENT

There Must Be An Easier/better Way...

Oct 26, 2005

I have a database with table representing city blocks, houses, and people.  On my main aspx page, I have a datagrid which displays a list of the blocks, followed by a count of the houses in each block, followed by a count of the people in each block.  Right now I have something that works, but it is awful.  Every time the page loads it makes a ton of connections to the database, and I have convoluted spaghetti code.  Now I need to add more functionality, but I can't rightly do that until I find a more efficient way to do this.Step one.  The program connects to the database and gets a list of the blocks using the statement "SELECT blockid FROM blocks"Step two: The program iterates through each blockid in the list and executes the statement "SELECT houseid FROM houses WHERE blockid = (whatever)"Step three: The program counts the rows returned from step two to determine the count of how many houses are in that block. Step four: The program iterates through each houseid from step two and exectues the statement "SELECT COUNT (personid) FROM people WHERE houseid = (whatever)" the result is added to a variable that keeps a running count.Step five: the final value of the variable in step four is the number of people in that block.My question for you is, how can this be done more efficiently?  Can I group together some awesome SQL statement that will get these counts?  I thought about doing something like "SELECT blockid (SELECT COUNT houseid FROM houses WHERE blockid = something) as HouseCount" but I can't figure out how I could take the value in the first column (blockid) and pass it to the inner select statement.Any thoughts on how to make this better?  Below is the full code for my function, in case you want to examine in more detail.  Also, I am in the process of changing the select statements into stored procedures, so don't beat me up too badly over that bit of ugliness in my function.  Thanks.Private Function GetBlockDataSet() As DataSet        Dim myconnection As SqlConnection        Dim objDataAdapter As SqlDataAdapter        Dim query, connectionstring As String        Dim tempDS As New DataSet        Dim houseDS As New DataSet        Dim peopleDS As New DataSet        Dim DC1 As New DataColumn        Dim DC2 As New DataColumn        Dim i, j, peoplecount As Int32        Dim DR, DR2 As DataRow
        query = "SELECT blockid FROM blocks"        connectionstring = configurationsettsing.appsettings("ConnectionString")
        myconnection = New SqlConnection(connectionstring)        objDataAdapter = New SqlDataAdapter(query, myconnection)        objDataAdapter.Fill(tempDS, "BlockList")
        DC1.DataType = System.Type.GetType("System.Int32")        DC2.DataType = System.Type.GetType("System.Int32")        DC1.ColumnName = "HouseCount"        DC2.ColumnName = "PeopleCount"        tempDS.Tables("BlockList").Columns.Add(DC1)        tempDS.Tables("blockList").Columns.Add(DC2)
        i = 0        For Each DR In tempDS.Tables("BlockList").Rows            query = "SELECT houseid FROM Houses WHERE blockid = '"            query &= tempDS.Tables("BlockList").Rows(i).Item(0)            query &= "'"            objDataAdapter = New SqlDataAdapter(query, myconnection)            objDataAdapter.Fill(houseDS)
            tempDS.Tables("BlockList").Rows(i).Item(1) = _                houseDS.Tables(0).Rows.Count            tempDS.Tables("BlockList").Rows(i).Item(2) = 0            j = 0            peoplecount = 0            For Each DR2 In houseDS.Tables(0).Rows                query = "SELECT COUNT (personid) FROM people WHERE HouseID = '"                query &= houseDS.Tables(0).Rows(j).Item(0)                query &= "'"                objDataAdapter = New SqlDataAdapter(query, myconnection)                objDataAdapter.Fill(peopleDS)                peoplecount += peopleDS.Tables(0).Rows(0).Item(0)                j = j + 1                peopleDS.Clear()            Next            tempDS.Tables("BlockList").Rows(i).Item(2) = peoplecount            houseDS.Clear()
            i = i + 1        Next
        GetBlockDataSet = tempDS        ' Here comes the garbage collection        myconnection.Close()        myconnection.Dispose()        myconnection = Nothing        objDataAdapter.Dispose()        objDataAdapter = Nothing        tempDS.Dispose()        tempDS = Nothing        houseDS.Dispose()        houseDS = Nothing        peopleDS.Dispose()        peopleDS = Nothing        DC1.Dispose()        DC1 = Nothing        DC2.Dispose()        DC2 = Nothing
 
    End Function

View 5 Replies View Related

Can I Do This An Easier Way?

Apr 20, 2007

This statement returns date formatted 'yyyymmdhhnn'. But there has to be an easier way. Can someone help?

DECLARE @dt datetime;
SELECT @dt = GETDATE();
SELECT CONVERT(varchar(40),@dt,112) +
RIGHT('0' + CAST(DATEPART("hh", @dt) AS varchar(2)), 2) +
RIGHT('0' + CAST(DATEPART("mi", @dt) AS varchar(2)), 2) AS isodt;

Thank you.

View 4 Replies View Related

Is There Any Easier Way Than Using This Cursor?

Feb 20, 2008



Hello,

I just finished a lengthy process (for me) of writing this cursor that gets each row from the Fact table, and creates a running total of the billable hours (hours from rows where BillableType = 1). It starts over when the month changes, the year changes, or the employee changes.

I did this again for a running total of billable hours for the year.

I put these in 2 stored procedures and run them in an Execute SQL control flow task in my SSIS package. It seems like SSIS is designed to make this kind of procedure simpler, and I'm wondering if I'm doing this in the best way, or if there's a more efficient way to do this using tasks inside SSIS. Can anyone advise? Any help is greatly appreciated.

Best,
Andy




Don't feel obligated to read this cursor if you understand the problem above. It's not color coded because when I copied it from SQL I lost the tabbing on the case expressions.





Code Snippet

CREATE PROCEDURE YearTotalHours AS

DECLARE @FactBillingId Int;
DECLARE @dt DateTime;
DECLARE @EmpKey Int;
DECLARE @YearTotalHours Float;
DECLARE @NewYearTotalHours Float;
DECLARE @NewYear Int;
DECLARE @BillableType Int;


DECLARE FactBillingFinalRows CURSOR FOR
SELECT FactBillingId
FROM FactBillingFinal

OPEN FactBillingFinalRows

FETCH NEXT FROM FactBillingFinalRows
INTO @FactBillingId

WHILE @@FETCH_STATUS = 0
BEGIN




SET @EmpKey = (SELECT EmployeeKey FROM FactBillingFinal WHERE FactBillingId = @FactBillingId)
SET @dt = (SELECT dt FROM FactBillingFinal WHERE FactBillingId = @FactBillingId)
SET @BillableType = (SELECT BillableTypeKey FROM FactBillingFinal WHERE FactbillingId = @FactBillingId)
SET @NewYear = (SELECT Year(@dt))
SET @NewYearTotalHours =


CASE
WHEN @FactBillingId = 1 THEN
CASE
WHEN @BillableType = 1 THEN (SELECT Hours FROM FactBillingFinal WHERE FactBillingId = @FactBillingId)
ELSE 0
END
ELSE
CASE
WHEN @EmpKey <> (SELECT EmployeeKey FROM FactBillingFinal WHERE FactBillingId = @FactBillingId - 1)
THEN
CASE
WHEN @BillableType = 1 THEN (SELECT Hours FROM FactBillingFinal WHERE FactBillingId = @FactBillingId)
ELSE 0
END
ELSE
CASE
WHEN YEAR(@dt) = (SELECT YEAR(dt) FROM FactBillingFinal WHERE FactBillingId = @FactbillingId - 1)
THEN
CASE
WHEN @BillableType = 1
THEN (SELECT @YearTotalHours + (SELECT Hours FROM FactBillingFinal WHERE FactBillingId = @FactBillingId))
ELSE
CASE
WHEN @NewYearTotalHours IS NULL
THEN 0
ELSE @NewYearTotalHours
END
END
ELSE
CASE
WHEN @BillableType = 1 THEN (SELECT Hours FROM FactBillingFinal WHERE FactBillingId = @FactBillingId)
ELSE 0
END
END


END
END



UPDATE FactBillingFinal SET YearTotalHours = @NewYearTotalHours WHERE FactBillingId = @FactBillingId

SET @YearTotalHours = @NewYearTotalHours;

FETCH NEXT FROM FactBillingFinalRows
INTO @FactBillingId
END

CLOSE FactBillingFinalRows
DEALLOCATE FactBillingFinalRows




View 9 Replies View Related

Plz Tel Me Easier Way 2 Solve This Problem

Jan 7, 2008

Hi,

I have a table load which has load value for each hour.ie load_1,load_2...load_24... I want to find the max value between the 24 hourly loads and assign it to a variable say load_max...


Format of table
load_ID load_1 load_2 load_3 load_4 load_5 load_6...... load_24
1 2 4 5 6 7 8 23 56 44 22 64 33 67 24 345 34 75 57 24 23 24 24 66 789

These are the 24 load values with the load _id
I have lots of rows with load_id starting from 1- 100
Output should be to display the load_Id,load_max, load_min for each row...(after comparing the 24 loads with each other)
How can I do it with sql server.

View 7 Replies View Related

Easier Email Alerts From Sql 7/2000?

Oct 5, 2006

hi,

i get just as frustrated each time i try to configure email alerts on failed jobs on ms sql, it is beyond me why microsoft couldn't just let you point out an SMTP server to send through and be done with it.

is there a way to avoid having to setup an email client on our sql 7 and 2000 servers through some 3rd party app or other simple solution?

thanks in advance,
daniel

View 2 Replies View Related

Easier Method To Remove And Add A Table To Database?

Feb 22, 2000

I have a table that is corrupted and want to remove and add a backup version of it. How can i remove this table and add it again preserving all the foregin key restraints, permissions, dependencies, etc? Simply exporting and importing does not work. I could painfully remove the table and then painfully reconnect it again, recreating all the foreign key restraints, etc, by hand; but there has to be an easier way! What is the How-to?

Thank you!

Llyal

View 1 Replies View Related

Easier Way Of Building Pivot Tables In MS SQL Server

Jul 10, 2007

Dear AllI am very new to MS SQL Server and I am wondering is there some toolwhich would allow me to build pivot tables in SQL more easily. At themoment writing a query can be quite challenging and difficult.Is there any software which allows you to do it more intuitively andgives you some visual feedback about query you are building?I would be very grateful for any help with this.wujtehacjusz

View 2 Replies View Related

What Solutions Make Returning From A Disaster Easier?

Apr 18, 2007

I'm trying to figure out what solution (replication, mirroring, clustering) would work best for me.

I have been reading many articles in BOL and in this forum. Most talk about getting data TO a backup/standby/subscriber, but I can't find a lot of info regarding getting the data BACK after a disaster is over.

We have a main office and a disaster recovery facility. Most of the time there are no data updates at the disaster location. So, I need to get data to the disaster facility via WAN (latency is not a huge issue - end of day syncing is fine) for backup purposes. In the event of a disaster, the main office will be offline and data changes will happen at the disaster site. When the disaster is "over" and we return to the main office, what's the best scheme to reverse the data back to the main office to start business again? We are a financial company, and have gigabytes of relatively static data. Most changes are current day. So, to snapshot a 100GB database when I know only a few hundred MB changes a day doesn't seem feasible to me.

Most replication scenarios (at least from what I see) can't easily "reverse" the replication after a disaster situation. I'm looking at merge replication on a schedule which seems to look good, but was wondering if anyone else has any ideas or suggestions?

View 5 Replies View Related

Subquery, Select Case, Pivot Help. Is There An Easier Way?

Apr 12, 2008



I'm trying to select from a table with three columns. I want these columns to be spread out among multiple columns based on the values. I hope someone can shed some light on this. I might be able to use pivot, but don't know how the syntax would roll for this.

Here is the example of dummy values and the output I am trying to obtain.




drop table table1

create table table1

(Category int, Place int, Value int)

insert into table1 values

(1, 1, 20)

insert into table1 values

(1,2, 12)

insert into table1 values

(1,3, 30)

insert into table1 values

(2,1, 34)

insert into table1 values

(2,2, 15)

insert into table1 values

(2,3, 78)



select Category,

(select top 1 value from table1 where place = 1 and Category = t1.Category) as place1,

(select top 1 value from table1 where place = 2 and Category = t1.Category) as place2,

(select top 1 value from table1 where place = 3 and Category = t1.Category) as place3

from Table1 t1

group by Category




Thanks for the help.

View 5 Replies View Related

There Must Be An Easier Way - Dupe Check And Increment Field

Nov 11, 2006

Greetings all,

I have a bit of brainteaser that's going to take some serious thought.

I'm importing information from .xls files into a SQL table. The problem is I need to check for dupes and increment certain fields on success of dupe find and then not insert or delete the dupes.

For example, if I have Adam, Turner, 32, 50 already in the table and someone tries to insert Adam, Turner, 32, 50...I need it to increment to read Adam, Turner, 64, 100 and not insert the record. (Notice 2 fields were incremented.)

With that, I have created an INSERT trigger as follows:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER Trigger [dbo].[trgInsertCheck]
ON [dbo].[MyTable]
FOR INSERT
AS
BEGIN
   EXEC sp_UpdateDupes
   EXEC sp_DeleteDupes
END

The first stored procedure checks for dupes and updates if any dupes are found as follows:
--------------------------------------------------------------------------------------------------------------------------------------

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[sp_UpdateDupes] AS

DECLARE @FirstName varchar(20), @LastName varchar(20), @Age int,  @Widgets int
DECLARE c1 CURSOR FOR

SELECT FirstName, LastName, Age, Widgets
FROM MyTable
GROUP BY FirstName, LastName, Age, Widgets
HAVING COUNT(*) > 1

OPEN c1
FETCH NEXT FROM c1
INTO @FirstName, @LastName, @Age, @Widgets
WHILE @@FETCH_STATUS = 0
BEGIN



UPDATE MyTable set Widgets = Widgets + @Widgets, Age = Age + @Age
WHERE FirstName = @FirstName AND LastName = @LastName

FETCH NEXT FROM c1
INTO @FirstName, @LastName, @Age, @Widgets
END
CLOSE c1
DEALLOCATE c1

Lastly, it finds all dupes, deletes them and inserts one row back in as follows:
--------------------------------------------------------------------------------------------------------------

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[sp_DeleteDupes] AS

DECLARE @FirstName varchar(20), @LastName varchar(20), @Age int, @Widgets int --declare all fields in table

DECLARE c1 CURSOR FOR

SELECT FirstName, LastName, Age, Widgets
FROM MyTable
GROUP BY FirstName, LastName, Age, Widgets
HAVING COUNT(*) > 1

OPEN c1
FETCH NEXT FROM c1
INTO @FirstName, @LastName, @Age, @Widgets
WHILE @@FETCH_STATUS = 0

BEGIN
--Delete all dupes...the cursor remembers the current record

DELETE FROM MyTable
WHERE FirstName IN (SELECT FirstName FROM MyTable GROUP BY FirstName HAVING COUNT(FirstName) > 1)
AND LastName IN (SELECT LastName FROM MyTable GROUP BY LastName HAVING COUNT(LastName) > 1)
AND Age IN (SELECT Age FROM MyTable GROUP BY Age HAVING COUNT(Age) > 1)
AND Widgets IN (SELECT Widgets FROM MyTable GROUP BY Widgets HAVING COUNT(Widgets) > 1)

--insert the current record back into the table

INSERT INTO MyTable(FirstName, LastName, Age, Widgets) VALUES(@FirstName, @LastName, @Age, @Widgets) 

FETCH NEXT FROM c1
INTO @FirstName, @LastName, @Age, @Widgets
END
CLOSE c1
DEALLOCATE c1

Is there an easier way to do this?

(I know Age doesn't make much sense in this example but just replace it with a field would logically be incremented such as wadgets.)

Adamus

View 7 Replies View Related

Is There An Easier Way? Two Aggregate Fields From One Based On Dates

Oct 19, 2007

When I was looking at this I knew that I've done this same issue before without using temp tables at all but I need a push to to jar it loose.

I have a table like this:







Balance
Date

1
200
2/14/2000

2
350
2/14/2000

3
32
2/14/2000

2
723
2/14/1998

3
354
2/14/1998





1
321
2/14/2000

2
673
2/14/1998

3
581
2/14/2000

2
574
2/14/1998

3
50
2/14/2000

1
10
2/14/2000

And essentially need this.










Total Balance Before 1/1/2000
Total Balance After 1/1/2000

1
0
531

2
1970
350

3
354
663



Right now I'm splitting it into two temp tables and then joining them together.

Temp Table 1 has the sum of the balance grouped by field1 before 1/1/2000 and Temp table 2 has the after 1/1/2000 criteria.

Table 1 gets updates with field1 values from table 2 that aren't already there. And then the balance field after 1/1/2000 is merged in.

Utimately this will be used in a SPROC for a Multivalued SSRS report.

View 3 Replies View Related

How To Do 2 Things In T-SQL

Apr 19, 2002

I am writting a T-SQL script to install my database. I have figured out all the sets except 2 areas.

1. Give login db_datareader / db_datawriter permissions to a DB
2. Add a DTS Package, it uses a script, and schedule it.

Here's how I do them in EM....

Issue 1: Security - Logins,
Right click on login, select properties
In database access tab, check Permit for DB
In database role, check public, db_datareader, db_datawriter.

Issue 2: DTS - Local Packages
Right click on local package, new package.
Create SQL connection & exe SQL task (attach seperate SQL script)
Save
Right click on newly created package and schedule

View 2 Replies View Related

Strange Things

Dec 6, 2007

Hello everybody ,
I want you to explain me something that i find a little strange.
Yesterday i had a problem with a huge log file and a friend in here helped me fix this by making a log back up and then shrinking it to 200 MB.Everything went fine.When i returned home i tried something else in a test environment..Here what happened:
I Got a full database back up.
I dropped the database.
I created a new one with 1GB mdf and 250MB ldf.
I vanished the log back -up
I restored the mdf file on the new database
The log file again had the same huge size after the restore.
How did this happen?


I sell my mother in law.Is anybody interested?

View 6 Replies View Related

Heaps Of Things

Feb 12, 2008



Hi all,
a question that has been in my mind for a while:

A HEAP is a table that has no clustered index.

Now consider a table that has a unique clustered index (primary key) on an identity column ?

For example:

create table Test
(
TestId int identity(1,1) not null,
...,
constraint PK_Test primary key clustered (TestId)
)

Is there a recognised term for such a table ?

Thanks
Graham

View 4 Replies View Related

Things To Consider While Designing Database

Dec 5, 2005

One interviewer has asked me the following question:
What are the things that you consider while designing database?
I have told about integrity constraints, and normal forms.
but he has added 15 more concepts like
1. indexers
2. Table columns
3. Table rows
4. search facilities
6.......
Can any one give full Idea on this question?
Thanking you     Ashok kumar.

View 1 Replies View Related

Things You Didnt Knew Before

Aug 23, 2005

A book is like a garden carried in the pocket.


<edit> links removed </edit>

View 1 Replies View Related

Count(*) Locking Up Things ...

Oct 28, 2005

SQL 2000I have inherited an application where many of the automated processescall a proc that simply returns the number of records with a NEWstatus.In watching the process in SQL, I see this ends up blocking a lot ofprocesses - many like this are called every 5-30 seconds ...I wish to replace COUNT(*) with EXISTS if that will make things operatefaster with no locks ...Thoughts ...Thanks everyone !!Craig

View 1 Replies View Related

Things I Didn't Know Until Today

Jan 24, 2007

You can use a Select top @variable in sql server 2005:Thus:--'Throttle' the result set:Select Top (@MaxBatchSize)KeyID, LId, ArrivalDt, CaptureDt, Lat, LongFrom GPSDataOrder By CaptureDt DescMakes messing with Set Rowcount *so* redundant :-)

View 1 Replies View Related

A Couple Of Things With My New Report

May 11, 2007

I have made a report in SRS and am not sure of how to do some of the functions I need.

In SQL I can use UPPER to convert to upper case, SRS doesn't seem to like this. The report runs but the line that is to be upper case is missing. If I remove the UPPER word from my query it works fine just displaying in lower case. Am I doing something wrong?

In Excel 2007 (I am converting my report from Excel to SRS) there is a function called NETWORKDAYS (Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term.) Is there something similar I can use in SRS?


Thanks.

View 3 Replies View Related

A Few Things To Do With Store Variables.

Jul 24, 2007

Okay,

I'm creating a small application for my local school district that will allow them to do a small management of inventory.

Is there a way to create an executable script that will create the default databases the first time? If so, what all do I need to do for the script and to make it execute?
I want to make a section in my OPTIONS area where users can put the path to their db (will not be hosted on the same PC as the software) along with the username and password for the db. I know I can store this information in a predetermined variable in the program so that it can reference it off and on.



Could someone please help me with this..... If it's in the wrong forum please let me know.



Thanks,

QWERTYtech

View 5 Replies View Related

What Data Type To Use For This Different Things

Jun 16, 2007

Hello.

I am a newbe in this and I tried to find the information on the msdn but could not find a god answer.

I am using VisualStudio Express 2005 and a SQL Server Express version.

In a Visual Basic application I use "radio buttons", "tick boxes", "Combo Boxes" and "Numeric Up Down".

But I cant figure out what data type to use to save the data in a SQL server.

It would be nice to have a document that maps the different data types to use in SQL Server according to what object you are using in the Visual Studio.

Thanks in advance.

/Martin

View 1 Replies View Related

Odd Things...I'm Totally Stuck

Aug 6, 2007



Hi all of you,

I've got a .dtproj project along with 10 dtsx packages. Up to here everything is fine, every package have its own source files, sql destinations and so on..
Issue comes when I try create a flat file source connection for the eleven one.

I get this message:

The component has detected potential metadata corruption during validation.
Error at Data Flow Task [Flat File Source [1]]: Failed to find any non-special error column in output "Flat File Source Error Output" (3).

It may not be possible to recover to a valid state using a component-specific editor. Do you want to use the Advanced Editor dialog box for editing this component?

Otherwise if I'm gonna to open a new .dtproj project separately no problem at all, I mean, appears the suitable window, "Connection Manager", "Column", "Error output" on the left and so on..

It's very strange. The rest of the packages, the same situation. Fortunately, all of them are stored on the server.

I don't get the point at all. Could you please tell me what the hell is happening?

Thanks in advance and regards,

View 3 Replies View Related

SSIS Configuration Files - How Do You Use The Things?

Oct 16, 2006

http://blogs.conchango.com/jamiethomson/default.aspx has a lot of great tid-bits for SQL 2005.  I am currently on a tight deadine for 25 SSIS packages that need to be able to move from Dev to QA to Staging to Prod.  For the life of me I cannot get any of the packages to *READ* the config files created with the package config wizard.  All I want to do is move the connection string out of the package so we can change the config file and not have to touch (hand edit) each package. Any help is appreciated! 

View 13 Replies View Related

Count All Things Happened Today

Nov 11, 2007

Ive got a table of notes people have created, with a field called "timecreated" which has a default value of "GETDATE()" Im trying to write an SQL statement that will count up all of the notes that people have created today/ yesturday etc. i could do it if the timecreated value was a "short date string" styled date, but its set up like  : 11/11/2007 18:51:46 is there way of converting it before counting? if theres a simple way of doing this i would appricate any help thanks John

View 7 Replies View Related

Stored Procedures: How In The World Do I Use These Things?

Apr 11, 2008

I was told I can use them with SQLDataSources, but I have no clue how to do it.
I believe I have managed to set up the querry in the datasource correctly, but what do I need to do to actually use it in my VB code?
 
Any help is appreciated, and any tutorials you've found to be usefull on the subject are sure to help.
Thanks

View 3 Replies View Related

Strange Things Happens With Identity Column

Apr 2, 1999

Hi Friends

I have a identity column in a table, while adding records,
it fills the column with different values, for eg. 75 after 90.
In which situation, it may occur and how to solve this.

Thanks in advance.

Rajasekar

View 2 Replies View Related

Fixed A Few Things Still Having A GROUP Error

Feb 16, 2007

Hello,

Here is the code as it now stands:


select TECHN, RESCODE,
(CASE
WHEN TECHN IS NOT NULL AND RESCODE IS NOT NULL AND COMPLET IS NULL THEN 'TOTAL RESCODE'
when TECHN IS NOT NULL AND RESCODE IS NULL THEN 'TOTAL TECH'
ELSE CONVERT(VARCHAR, CAST(COMPLETE AS DATETIME), 105) END) COMPLETE, DESCRIPTION, RES_NAME, ADDRESS, JOB, TYP, NUM, OPR, sum(QTYW) QTY, sum(NCommissionAMT) CommissionAUT
FROM
(select ir_tech_ojb TECHN
, substring (compl_cde_ojb, 1, 3) RESCODE
, compl_dte_ojb COMPLET
, CodeDes DESCRIPTION
, res_name_sbb RES_NAME
, ADDR1_HSE ADDRESS
, job_typ_ojb JOB
, job_class_ojb TYP
, order_no_ocr NUMB
, ls_chg_op_id_ocr OPR
, CommissionAMT NCommissionAMT
, COUNT(DISTINCT order_no_ocr) QTYW
from Parser.dbo.Parser_ocr
Inner Join Parser.dbo.Parser_ojb on order_no_ocr = order_no_ojb
Inner JOIN Parser.dbo.RGV_Codes on substring (compl_cde_ojb, 1, 3) = CODE
Inner JOIN csg_hist.dbo.sbb_base on hse_key_ocr = hse_key_sbb
Inner JOIN csg_hist.dbo.hse_base on hse_key_ocr = hse_key_hse
where substring (compl_cde_ojb, 1, 3) = CODE
and ir_tech_ojb between 950 and 999
and compl_dte_ojb BETWEEN '2007-01-09' AND '2007-01-22'
and prin_ocr = 8600
GROUP BY ir_tech_ojb, substring (compl_cde_ojb, 1, 3),compl_dte_ojb,CodeDes, res_name_sbb, ADDR1_HSE,
job_typ_ojb, job_class_ojb, order_no_ocr, ls_chg_op_id_ocr, CommissionAMT
union all
select ir_tech_ojb TECHN
, substring (compl_cde_ojb, 4, 3) RESCODE
, compl_dte_ojb COMPLET
, CodeDes DESCRIPTION
, res_name_sbb RES_NAME
, ADDR1_HSE ADDRESS
, job_typ_ojb JOB
, job_class_ojb TYP
, order_no_ocr NUMB
, ls_chg_op_id_ocr OPR
, CommissionAMT NCommissionAMT
, COUNT(DISTINCT order_no_ocr) QTYW
from Parser_ocr
Inner Join Parser_ojb on order_no_ocr = order_no_ojb
Inner JOIN RGV_Codes on substring (compl_cde_ojb, 1, 3) = CODE
Inner JOIN csg_hist.dbo.sbb_base on hse_key_ocr = hse_key_sbb
Inner JOIN csg_hist.dbo.hse_base on hse_key_ocr = hse_key_hse
where substring (compl_cde_ojb, 4, 3) = CODE
and ir_tech_ojb between 950 and 999
and compl_dte_ojb BETWEEN '2007-01-09' AND '2007-01-22'
and prin_ocr = 8600
GROUP BY ir_tech_ojb, substring (compl_cde_ojb, 4, 3),compl_dte_ojb,CodeDes, res_name_sbb, ADDR1_HSE,
job_typ_ojb, job_class_ojb, order_no_ocr, ls_chg_op_id_ocr, CommissionAMT
union all
select ir_tech_ojb TECHN
, substring (compl_cde_ojb, 7, 3) RESCODE
, compl_dte_ojb COMPLET
, CodeDes DESCRIPTION
, res_name_sbb RES_NAME
, ADDR1_HSE ADDRESS
, job_typ_ojb JOB
, job_class_ojb TYP
, order_no_ocr NUMB
, ls_chg_op_id_ocr OPR
, CommissionAMT NCommissionAMT
, COUNT (DISTINCT order_no_ocr) QTYW
from Parser_ocr
Inner Join Parser_ojb on order_no_ocr = order_no_ojb
Inner JOIN RGV_Codes on substring (compl_cde_ojb, 1, 3) = CODE
Inner JOIN csg_hist.dbo.sbb_base on hse_key_ocr = hse_key_sbb
Inner JOIN csg_hist.dbo.hse_base on hse_key_ocr = hse_key_hse
where substring (compl_cde_ojb, 7, 3) = CODE
and ir_tech_ojb between 950 and 999
and compl_dte_ojb BETWEEN '2007-01-09' AND '2007-01-22'
and prin_ocr = 8600
GROUP BY ir_tech_ojb, substring (compl_cde_ojb, 7, 3),compl_dte_ojb,CodeDes, res_name_sbb, ADDR1_HSE,
job_typ_ojb, job_class_ojb, order_no_ocr, ls_chg_op_id_ocr, CommissionAMT
union all
select ir_tech_ojb TECHN
, substring (compl_cde_ojb, 10, 3) RESCODE
, compl_dte_ojb COMPLET
, CodeDes DESCRIPTION
, res_name_sbb RES_NAME
, ADDR1_HSE ADDRESS
, job_typ_ojb JOB
, job_class_ojb TYP
, order_no_ocr NUMB
, ls_chg_op_id_ocr OPR
, CommissionAMT NCommissionAMT
, COUNT(DISTINCT order_no_ocr) QTYW
from Parser_ocr
Inner Join Parser_ojb on order_no_ocr = order_no_ojb
Inner JOIN RGV_Codes on substring (compl_cde_ojb, 1, 3) = CODE
Inner JOIN csg_hist.dbo.sbb_base on hse_key_ocr = hse_key_sbb
Inner JOIN csg_hist.dbo.hse_base on hse_key_ocr = hse_key_hse
where substring (compl_cde_ojb, 10, 3) = CODE
and ir_tech_ojb between 950 and 999
and compl_dte_ojb BETWEEN '2007-01-09' AND '2007-01-22'
and prin_ocr = 8600
GROUP BY ir_tech_ojb, substring (compl_cde_ojb, 10, 3),compl_dte_ojb,CodeDes, res_name_sbb, ADDR1_HSE,
job_typ_ojb, job_class_ojb, order_no_ocr, ls_chg_op_id_ocr, CommissionAMT
union all
select ir_tech_ojb TECHN
, substring (compl_cde_ojb, 13, 3) RESCODE
, compl_dte_ojb COMPLET
, CodeDes DESCRIPTION
, res_name_sbb RES_NAME
, ADDR1_HSE ADDRESS
, job_typ_ojb JOB
, job_class_ojb TYP
, order_no_ocr NUMB
, ls_chg_op_id_ocr OPR
, CommissionAMT NCommissionAMT
, COUNT(DISTINCT order_no_ocr) QTYW
from Parser_ocr
Inner Join Parser_ojb on order_no_ocr = order_no_ojb
Inner JOIN RGV_Codes on substring (compl_cde_ojb, 1, 3) = CODE
Inner JOIN csg_hist.dbo.sbb_base on hse_key_ocr = hse_key_sbb
Inner JOIN csg_hist.dbo.hse_base on hse_key_ocr = hse_key_hse
where substring (compl_cde_ojb, 13, 3) = CODE
and ir_tech_ojb between 950 and 999
and compl_dte_ojb BETWEEN '2007-01-09' AND '2007-01-22'
and prin_ocr = 8600
GROUP BY ir_tech_ojb, substring (compl_cde_ojb, 13, 3),compl_dte_ojb,CodeDes, res_name_sbb, ADDR1_HSE,
job_typ_ojb, job_class_ojb, order_no_ocr, ls_chg_op_id_ocr, CommissionAMT
union all
select ir_tech_ojb TECHN
, substring (compl_cde_ojb, 16, 3) RESCODE
, compl_dte_ojb COMPLET
, CodeDes DESCRIPTION
, res_name_sbb RES_NAME
, ADDR1_HSE ADDRESS
, job_typ_ojb JOB
, job_class_ojb TYP
, order_no_ocr NUMB
, ls_chg_op_id_ocr OPR
, CommissionAMT NCommissionAMT
, COUNT(DISTINCT order_no_ocr) QTYW
from Parser_ocr
Inner Join Parser_ojb on order_no_ocr = order_no_ojb
Inner JOIN RGV_Codes on substring (compl_cde_ojb, 1, 3) = CODE
Inner JOIN csg_hist.dbo.sbb_base on hse_key_ocr = hse_key_sbb
Inner JOIN csg_hist.dbo.hse_base on hse_key_ocr = hse_key_hse
where substring (compl_cde_ojb, 16, 3) = CODE
and ir_tech_ojb between 950 and 999
and compl_dte_ojb BETWEEN '2007-01-09' AND '2007-01-22'
and prin_ocr = 8600
GROUP BY ir_tech_ojb, substring (compl_cde_ojb, 16, 3),compl_dte_ojb,CodeDes, res_name_sbb, ADDR1_HSE,
job_typ_ojb, job_class_ojb, order_no_ocr, ls_chg_op_id_ocr, CommissionAMT)
group by rollup(TECHN, RESCODE,(COMPLET, DESCRIPTION, RES_NAME, ADDRESS, JOB, TYP, NUMB, OPR))
order by 1, 2,3, 5;


Msg 156, Level 15, State 1, Line 150
Incorrect syntax near the keyword 'group'.

Could the error message be in the INNER JOIN?

What do I need to check for next.

Thanks for eveyrone's help so far.



Kurt

View 20 Replies View Related

Join Excludes Things It Shouldn't

Feb 28, 2008

I've got a problem with this query. I'm not great at joins and so I'm not sure how to fix this.
I have items not in the CMO table (the last join), but I still want them to at least show up. They're being excluded:

SELECT OM.DOCNUM, OM.NAME_LAST, OM.NAME_FIRST, LV.DESCRIPTION AS Sex, ' ' AS Mandatory, CASE WHEN (LSI.Q1 = 1 OR
LSI.Q2 = 1 OR
LSI.Q3 = 1 OR
LSI.Q4 = 1 OR
LSI.Q5 = 1 OR
LSI.Q6 = 1 OR
LSI.Q7 = 1 OR
LSI.Q8 = 1 OR
LSI.Q9 = 1 OR
LSI.Q10 = 1 OR
LSI.Q12 = 1 OR
LSI.Q13 = 1 OR
LSI.Q14 = 1 OR
LSI.Q15 = 1 OR
LSI.Q16 = 1 OR
LSI.Q33 = 1 OR
LSI.Q34 = 1 OR
LSI.Q39 = 1 OR
LSI.Q39 = 0 OR
LSI.Q40 = 1 OR
LSI.Q40 = 0 OR
LSI.Q51 = 1 OR
LSI.Q51 = 0) THEN 'Y' ELSE ' ' END AS Optional, OM.CASE_MANAGER_ID_U AS CASE_MANAGER_ID,
CASE WHEN (CMO.REMOVAL_RSN_ID_LV = 1022) THEN 'Y' ELSE ' ' END AS Active, CASE WHEN (CMO.REMOVAL_RSN_ID_LV = 1015)
THEN 'Y' ELSE ' ' END AS Complete
FROM dbo.OFFENDER_MAIN AS OM LEFT OUTER JOIN
dbo.LOOKUP_VALUES AS LV ON LV.ID = OM.GENDER_ID_LV LEFT OUTER JOIN
dbo.LSI_ANSWERS AS LSI ON LSI.DOCNUM = OM.DOCNUM LEFT JOIN
dbo.COMMUNITY_MOD_OBJ AS CMO ON CMO.DOCNUM = OM.DOCNUM
WHERE (LSI.COMIT_ACTIVE = 1) AND (CMO.OBJECTIVE_CODE_ID_LV = 1011) AND (CMO.REMOVAL_RSN_ID_LV = 1022 OR
CMO.REMOVAL_RSN_ID_LV = 1015)
AND (OM.FACILITY_ID_F <> 1)

View 1 Replies View Related

GO Makes Things Hugley Faster

Oct 15, 2007

I have a data migration script that takes about an hour half to complete. The script conists of several insert statements that pull data from another sqlserver database while doing a fair amount of manipulation.

If I put a "go" in after every insert statement. The job finishes in 30Seconds. can some explain this huge performance change.

View 1 Replies View Related

HELP: ASP.NET Won't Connect To SQLexpress After Deploying To IIS, Try A Lot Of Things...

Jul 31, 2007

Hello,

I have finish building my ASP.NET site using VS 2005 and it compile just fine. Than I try hosting it to the web via IIS v5.1 and I am getting permission error from SQL express.

I have posted a detail question in experts-exchange.com and since you need a user account to even view the thread, I have taken the liberty to save the thread as .html file and host it to my ISP site. You can see the detail problem I am having here: http://users.accesscomm.ca/mm/EEdetail.html

I am going to list out some stuff I have done:

1. I have two database that need access, the ASPNETDB.mdf for user login and another database (PhotoDataBase.mdf) to store information relating to the photo I uploaded to my ASP.NET site.

2. I have already follow this How to site: http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx and setup:
- TCP/IP enable, as shown here:
- I have started SQL Browser service
- The firewall part I am not so sure about. I am currently using Zonealarm....

3. I have installed SQL Server Management Studio Express(SSMSE) and attach the two database to it.

4. I have set SSMSE server properties to accept both SQL and window authentication.

5. I have made sure that both database "read only" setting to false

6. I have setup SQL login with User ID = SQLLOGIN

Here is the original connection in web.config:
<add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|Da
taDirectory|PhotoDataBase.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />

and here is the new connection I just type in web.config that replace the original one:
<add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|PhotoDataBase.mdf; Server=MINGDESKTOP; Integrated Security=False; uid=SQLLOGIN; Password=XXXXXX;" providerName="System.Data.SqlClient" />

and the error i get are the follow:

Server Error in '/' Application.An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

7. I did haven't done much to ASPNETDB.mdf yet and the error i get right now are the following:

________________________________________
__________________
Server Error in '/' Application.
Cannot open user default database. Login failed.
Login failed for user 'MINGDESKTOPASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
Login failed for user 'MINGDESKTOPASPNET'.
_______________________________________________

Please help! I am really running out of ideas.... and I need to have this setup in a few days....

Thanks!

View 4 Replies View Related

Installation - Can't Remember One Of The Things I Installed...

Feb 21, 2008

Hello,

A while ago I installed SQL CE on my decive. Unfortunately, it crapped out at one point so I'm reinstalling what needs to be put back on. I'm pretty sure I just used the CAB files to do this (but I might be mistaken). In any case, I remember there being an application that allowed me to do queries, browse data, etc. on my device's databases... I'm pretty sure it was just something included with SQL CE.

I already have the CF installed. I have all of the SQL CE CABs installed as well (I think)... but for some reason I simply cannot remember what CAB or other installation that would contain the browser, query creation thing, and so on...

Anyone have any idea what I'm rambling on about? Thanks!

View 1 Replies View Related

Can I Achieve These Things Using Reporting Services?

Apr 17, 2008

I have a main report and some subreports.
What i want to achieve is the subreports would be dynamically sent parameters to and the layout would change depending on some
parameters sent from the main report.
So there ia going to be a main report that is constant but the subreports data and layout could change.

Another question is can i have an expression that would hide a subreport if there is no data in the subreport?

Any ideas would be appreciated

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved