Generating Overnight Data Vs Live - Suggestions Needed.

Jul 20, 2005

We have an MIS system which has approx 100 reports. Each of these
reports can take up to several minutes to run due to the complexity of
the queries (hundreds of lines each in most cases). Each report can be
run by many users, so in effect we have a slow system.

I want to seperate the complex part of the queries into a process that
is generated each night. Then the reports will only have to query
pre-formatted data with minimal parameters as the hard part will have
been completed for the users when they are not in. Ideally we will
generate (stored procedure possibly) a set of data for each report and
hold this on the server. We can then query with simpler parameters
such as by date and get the data back quite quickly.

The whole process of how we obtain the data is very complex. There are
various views which gather data from the back office system. These are
very complex and when queries are run against them including other
tables to bring in more data, it gets nicely complicated.

The only problem is that the users want to have access to LIVE data
from the back office system, specifically the Sales team who want to
access this remotely. My method only allows for data from the night
before, so is there an option available to me which will allow me to
do this ? The queries can't be improved on an awful lot, so they will
take as long as they take. The idea of running them once is the only
way I can see to improve the performance in any significant way.

True I could just let them carry on as they are and let them suffer
with the performance on live data, but I'd like to do something to
improve the situation for them.

Any advice would be appreciated.

Thanks

Ryan

View 2 Replies


ADVERTISEMENT

Suggestions Needed

Sep 7, 2007

What I have.
I have a spreadsheet that is used in 4 or more locations on a daily basis by 1-3 ppl per locations. The spreadsheet is used to gather Quality Control information. So everyday there are a couple of spreadsheets from each system that is used to generate weekly and monthly reports. This is becoming to much work and I would like to automate the process.

What I have access to.
I currently run a Sharepoint 2007 Server for all our collaboration and document needs.
I also have the ability to setup any sql server.

What I want.
I want the QC techs in each system to be able to upload the data at the end of each day and be done with it. This way they do not have email or do a weekly report.
I would prefer to use Sharepoint and create reports weekly and monthly that can be pulled just by going to a site.

I'm knowledgeable in Sharepoint and Excel. I have some skills in VBA. I haven't dealt with SQL any, but willing to learn.
Also I'm knowledgeable in Microsoft Access as well.



Any suggestions on how I could accomplish this would be appreciated.

TIA

View 1 Replies View Related

Web Based Reporting - Suggestions Needed

Jul 20, 2005

I want to create a web browser based MIS suite to use our data held onSQL 7. We have Dreamweaver and Crystal Reports available but I want toknow if these are suitable or if there are any recommendations forsomething I can pick up quickly.It will be simple reports based on complex queries (I can handle mostof this in SQL 7), don't need fancy graphs, just plain boringfinancial reports are what I need to produce.Obvious things I need to create are combo boxes and list boxes forselections. My background is more Delphi/VB and SQL than web basedstuff, so please let me know any recommendations or good places tostart looking.ThanksRyan

View 2 Replies View Related

Suggestions Needed - How To Setup A DB For Use With SQL 2005Express OR SQL 2005 Full?

Mar 21, 2008

Hello,
Background: I am a Software Engineer - not a DBA - with limited SQL knowledge (I know the SQL but not the configuration stuff)... I am sure others need this too - I tried but cannot find the answers online... please help me with a few questions:

Task: I need to find an way to install a database via Installshield 2008/command-line (silently), that is accessible locally and remotely regardless of what was already installed, and accessible only to our program - not users, so I am thinking use SA and a strong password since windows authentication may not apply with multiple users accessing this DB and they do not need to login on to the server - only our program does - sound right to use Mixed?).

Questions:
Can SQL 2005 Express be installed when SQL 2005 Full edition is already present?


Can SQL 2005 Express be installed without an instance name?
I think I read an instance name is required in Express, that if I do not provide it defaults to SQLEXPRESS -
So, if the prior question's answer is 'no, they cannot both exist'... prompting the next question:

If the Full version is already installed, should/can I use it - AND - can I add a New Instance silently via command line or ???

Any other ideas on why I can install 2005Express on one system, and not on two others (all 3 are development machines: VS 2005, SQL Express and that's about it)?
Currently I have figured out a command-line call to install - the command I came up with during testing is:
start /wait C: empSQLEXPR32.EXE /qb INSTANCENAME=CINST ADDLOCAL=ALL SECURITYMODE=SQL SAPWD=STR2PWD4SA SQLBROWSERACCOUNT="NT AUTHORITYNETWORK SERVICE" SQLACCOUNT="NT AUTHORITYNETWORK SERVICE" AGTACCOUNT="NT AUTHORITYNETWORK SERVICE" SQLBROWSERAUTOSTART=1 SQLAUTOSTART=1 AGTAUTOSTART=1 DISABLENETWORKPROTOCOLS=0 ERRORREPORTING=1 ADDUSERASADMIN=1
This looks like it might work for SQL Express 2005 - I do not have the full edition installed, yet - thus, this post.
The errors I got, shown in the summary.txt as 'Error 10' on one system with no other info.
My other system reports:
Microsoft SQL Server 2005 9.00.3042.00
==============================
OS Version : Microsoft Windows XP Professional Service Pack 2 (Build 2600)
Time : Fri Mar 21 16:45:25 2008

Machine : TONELSON
Product : Microsoft SQL Server Setup Support Files (English)
Product Version : 9.00.3042.00
Install : Successful
Log File : c:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0007_TONELSON_SQLSupport_1.log
--------------------------------------------------------------------------------
SQL Server Setup failed. For more information, review the Setup log file in %ProgramFiles%Microsoft SQL Server90Setup BootstrapLOGSummary.txt.
...not much to go on as to why it is failing - maybe the hotfix:
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGHotfixSQL9Express_Hotfix_KB921896_SQLEXPR.EXE
in the directory is blocking the install?

The goal is for my application to use the same connection strings regardless of 2005 full or 2005 express.

Need to figure this out -
Thank you,
Todd

Software Engineer/Developer... learning a lot about SQL

View 6 Replies View Related

Edit Live Sql Data?

Mar 31, 2006

I have a sql express database with a couple tables of information. I have a user modifying one of these tables with a data access page using Office Web Controls.

To backtrack a bit, the sql db used to be an access db. The same user modifying the data the same way. I also had a asp page making odbc calls to the access db to lookup information. But if the data access page was open, the odbc page would error. So i moved the data to sql.

Now, I'm getting ready to setup an application to make odbc calls to the sql db. I still want the user to modify the data using the DAP. Should I allow the user to modify the live data used for the app or should I make a copy of the data everytime its updated?

View 2 Replies View Related

Need Help With Producing Data On One Live

Jul 20, 2005

trying to make a script to view data in a excell spreadsheet.I can get all the data I need except one.select ordernumber, itemcode, quantity, rate, totalfrom dbo.chargeswhere ordernumber = '45676'the problem is there are more than one itemcodeexample: run resultsordernumber, itemcode, quantity, rate, total45676 fuel 123 .10 12.3045676 stops 3 50 150how do I get this data on one line?to look more like this: run resultsordernumber, itemcode, quantity, rate, total itemcode, quantity, rate, total45676 fuel 123 .10 12.30 stops 3 50 150now just one ordernumber appears and its all on one line.hope you can help, thanks for your time...Mike

View 1 Replies View Related

I Want To Have A Live Link To Data From SQL Server

Jun 27, 2005

This is a bit confusing but here goes:  I need to access data in SAP via OLE DB.  I can't go direct to the back end database (Oracle), we have to use RFC or BAPI calls to access the SAP data.  That's part works, we have a DLL that accesses the SAP data we need.

View 1 Replies View Related

Merging Row Data Or Any Suggestions

Feb 5, 2008

Hi
I have been given a table that contains data in this format:

SALESPERSON SALESPERSON_ID CLIENT DATE_FROM DATE_TO AGE
TOM 12345 NULL NULL NULL NULL
NULL NULL MARYSMITH 1/1/2008 12/31/2008 46
NULL NULL JANEDOW 1/1/2008 12/31/2008 24
ED 56789 NULL NULL NULL NULL
NULL NULL TOMJONES 1/1/2008 12/31/2008 65
ANTHONY 243546 NULL NULL NULL NULL
NULL NULL BEVBLACK 1/1/2008 12/31/2008 15
NULL NULL JEANTHOMAS 1/1/2008 12/31/2008 29

Basically this is ONE table that contains header and detail data ordered sequentially. There are not unique identifiers for the rows. The rows are ordered sequentially so that each SALESPERSON is followed by one or more CLIENTs.

If I could merge the rows, the result would look like:

SALESPERSON SALESPERSON_ID CLIENT DATE_FROM DATE_TO AGE
TOM 12345 MARYSMITH 1/1/2008 12/31/2008 46
TOM 12345 JANEDOW 1/1/2008 12/31/2008 24
ED 56789 TOMJONES 1/1/2008 12/31/2008 65
ANTHONY 243546 BEVBLACK 1/1/2008 12/31/2008 15
ANTHONY 243546 JEANTHOMAS 1/1/2008 12/31/2008 29


I am not how to do this with this data.

I also thought maybe it would be better to add unique identifiers to each set of SALESPERSONs/CLIENTs, and work with the data that way, but I am not sure how to do that.

Any help or suggestions would be appreciated. I have no ability to change this data - I have to try to work with it if possible.



JLH

View 4 Replies View Related

Data Transfer From Live To Backup Server

May 18, 2000

I have a live server running windows Nt and sql server We brought a new
backup server of higher configuration we wanted to swap the data we installed nt and sql server in the new server will a cut paste of the data directory of the live server to the backup server is sufficient or the data directory to be restored to the respective files through sql enterprise manager please do clarify me

Regards
Ramesh

View 1 Replies View Related

Restore Data From Live System To Test

Jun 16, 2015

I have two SQL Databases on separate servers, live and test. I have been asked to copy the data from the live system and put it into test. They are SQL Management Studio 2008 running on MS Server 2008R2.

Could a simple backup of the database, then copy that file to the test system and restore the database from that point work or it there more to it?

View 3 Replies View Related

Transaction Log Becomes Full Overnight

Apr 4, 2007

Hi guys,
I am developing this site http://www.onlineacademicadvisor.com and having DB problems for the 3rd time in a row.
Whenever the traffic on the site is getting bigger, the transaction log becomes full and no user can login. This problem is described at http://support.microsoft.com/kb/317375  From there, I got the feeling that the problem occurrs if transactions are not committed and last for too long.
However, I do not have any explicit transactions, just the usual select, insert, update statements in stored procedures. I do not call COMMIT (or RETURN) explicitly at the end of my stored procedures though. My stored procedures are short.
Have you got any ideas about what can cause the problem? I really have not idea what that could be.
Your help is much appreciated.

View 1 Replies View Related

Indexes Fragmenting Overnight

Jun 9, 2006

Over the past few days we noticed severe performance issues on some of our more complicated queries. I ran a DBCC ShowContig on the problematic tables, and noted that the Logical Scan Fragmentation was very high, like over 90%. I ran a DBCC DBREINDEX on the tables, the Logical Scan Fragmentation reduced down to between 0% and 10%, and the queries ran instantly.

However...the next day, the queries were causing problems again. Running ShowContig showed the fragmentation was up to over 90% again. Now, these are very static tables I'm dealing with...absolutely no UPDATE, INSERT or DELETE commands have been run against them (we import the data once a month). I set up a job to monitor the state of the index fragmentation overnight. All is well until 0100, when the LSF hits 90% again. I can't figure out what could be causing this, we have no jobs that run on, or affect, this database overnight, except the backup, which runs at 2100. Has anyone experienced anything like this before, or does SQL Server do something on the fly that could cause it to happen?

TIA!

View 5 Replies View Related

Real Time Live Data On A Windows Application .NET 2.0

Jan 10, 2006

I want to build a windows application in Visual Studio 2005 that grabs some data from a SQL DB and displays it in a gridview. That is easy and I already have it done, but I also want to know how to show this data in real-time. For example: right now we have a application that pulls some login information for all the users and displays their phone extension, their name, and their status. They can change their status by clicking on some radios below the datagrid and on change it updates the data and then posts back. However, I dont know how the guy who did it made it so that these local changes are automatically shown on everyone elses computers around the office. In other words, they are shown the live data as it changes, without having to refresh it or anything. How would I go about doing this or does anyone have any places/resources that could help me accomplish this task. Thanks.
Oh and the guy who wrote this is no longer working here and he deleted the source code so i cant look at it.

View 2 Replies View Related

SSRS :Generate Live Data Report (Example Stock)

Feb 21, 2008


Hello,


I have requirement to cache report server as soon as data get refreshed in datbase.My database get refreshed every 10 minutes.
I am working in stock and bond domain were data changes very frequently.My user want to see almost live data whenever accessing report in report manager.they also want to cache some data for better performance.Can any one tell me step's to improve performance of reporting services .
Kindly suggest me.

Thanks.
Monika Singh

View 11 Replies View Related

Move Data To Archive Table. Need Suggestions.

Mar 14, 2008

I have two tables say A and Archive. After a certain period of time some records are to be sent to archive table.To copy records to archive table I am using SqlBulkCopy operations.Now I have to delete the records from A Table. I was thinking of sending a Comma seperated id's of rows that are to be deleted to a stored procedure.Are there any better techniques to move data to archive table and to remove data from main table.?Thanks. 

View 9 Replies View Related

Process Dimensions And Cubes Overnight

Oct 13, 2004

Hi All, any advice or help greatly appreciated, I need to Process Dimensions and Cubes Overnight, what is the best and most reliable way of achieving this.

Many Thanks in anticipation.


Shurl

View 2 Replies View Related

Trapping 'curent Activity; In Batch Overnight?

Aug 17, 1999

Hello:

We are using Mssql 6.5, with sp4.

During the day I frequently use watch the current activity window under
Enterprise Manager to see who is doing what and when.

However, overnight there are various users running various jobs that I am
not always informed about. Wactcing the current activity isn't an option
here.

Does anyone have a job that I could periodically run overnight to perfrom
the same function as the current activty box? Which system tables does the
current activity functionality use?

Thanks. Any information that can be provided here will be appreciated.

DAvid Spaisman

View 1 Replies View Related

Transact SQL :: Replicating / Synching Data Between Two Tables On Same Database With Live Transactions

Oct 7, 2015

Client is running X- version of application and corresponding database size is huge. Now client's vendor is releasing Y-version of same application with many database schema changes (like new tables added, new columns added, renamed existing columns and etc) To upgrade to the Y-version, vendor is suggesting to my client that down the system and do the upgrade for application/database to Y-version. We are sure that this process will take days together to upgrade to the Y-version. My client is not ready to down the system for that long. So we are trying to find the solution with minimal down time.The approach we are thinking is, 

1) Create the replicated database to another server (server2) from production server(server1) using golden gate with X-version

2) Create new tables/schema updated tables from Y-version database on same server1. Here for  Updated schema tables we are planning to use the name <table_name_Y_version> as the same table name exists in X-version.

3)With above 2 steps, golden gate replicate the changes from production to server1 and server1 will have the new Y-version table schema (with different concatenate name ' _Y_version'). BTW , there is no affect for the production

4) At this stage we are planning to find best approach, to fill the '<table_name>_Y_version' from X-version tables. two challenges here a) all data needs to be moved to Y-version tables b) they have to sync data in real time.

we thought of going to

a) ssis package to pump the data to Y-version tables, but real time data will not sync.

b) trigger based technique, previous experience said, lot of load

c) thinking about sql replication.

View 5 Replies View Related

Scripting Overnight Backup Jobs For SQL Server Databases

Mar 21, 2008

Hi, I've just been given the task of finding out how to implement a backup procedure for our SQL server databases. Most are running 2000, some 2005.
I'm a programmer, and I'm used to having a DBA to help me! I've seen a few methods on the web involving a stored procedure and running the task from task manager.
I need to backup and restore all the databases in SQL Server 2000 and work out a way of displaying whether or not it was successful.
Can anybody please point me in the right direction as I've no idea how to do any of this really. I guess if I could setup a sproc to loop through the databases that would help, but I'm not sure where to start.
Thanks in advance.

View 9 Replies View Related

Generating Test Data In SQL Server

Jul 3, 2006

Hi,

I use SQL Server 2005 Dev Edition and am not new to making databases (then again, I've had enough experience and my dad does the same thing).

I am (unfortunately) a university student and for my dissertation I am going to produce a SQL Server database with a strong emphasis on data mining.

Obviously, for the data mining to be useful at all I need to produce loads and loads of test data.

Fair enough, and there are applications which do this, such as EMS Data Gen, but can anyone recommend me any other data gen utilities? EMS Data Gen has poor handling of unique attributes, and as I am doing a car manufacturer this will give me problems when I come to the registration number attribute.

Also, why are utilities for SQL Server (and Oracle at that) so expensive? This makes it out of my reach and makes it difficult to build a truly good database that will net me good marks, and demotivates me. :(

Lastly, please feel free to recommend to me any utilities for SQL Server - such as performance monitors, backup utilities. Anything. But if they are priced utilities, they have to be sensibly priced (<£100), because I cannot yet afford to pay >£1k on such utiltiies.

Thanks

View 1 Replies View Related

Generating Various Statistics From Data In MSSQL7

Jul 20, 2005

Sorry about the huge post, but I think this is the amount ofinformation necessary for someone to help me with a good answer.I'm writing a statistical analysis program in ASP.net and MSSQL7 thatanalyzes data that I've collected from my business's webpage and thehits it's collecting from the various pay-per-click (PPC) engines.I've arrived at problems writing a SQL call to generate certainstatistics.Whenever someone enters our site from one of the PPC search engines, Iwrite out a row to the Hits table. In that table are the followingcolumns:HitID - the Unique ID assigned to each hit that comes into the siteKeyword - the keyword the user searched on when he or she came to thesiteSearchEngine - the PPC engine the user came fromSource - this is pretty much always 'PPC'...if we were to do otherthings, like a newsletter, then this would be different.TimeArrived - the date and time the user arrived at the website. Ihave no idea why I didn't call it "datearrived," since I use "date"and not "time" pretty much everywhere else...(I don't think the rest are important, but they might be, so I'llinclude them for completeness's sake)Referring URL - the URL the user came fromReferring Website - the string between the 'http://' and the first '/'in the URL. I know it's redundant information, but when I designedthis part, I didn't know how to parse it out afterwards, so I justfigured I'd duplicate it.Page Visited - the page the user first arrived atWhen a person comes to the site, I also write out a session cookiecontaining the user's hitID. If the person fills out an enrollmentform (a process which we refer to as "responding"), I attach thatsession ID to the form. The response form (and thus the responsestable) is long; these are the important fields:id - a unique ID for each responsedate - the date and time of the responsestatus - a varchar field containing a status code. I would have madeit a number, but I wanted it to be viewable from looking at the rawdatabase.hitid - the HitID of the user, taken from the session cookie. If thereis no session cookie (for whatever reason), the HidID is written outas 0. While it wouldn't occur often, I can't guarantee that there willnever be more than one response record attached to a singular hitid.Later, some of the responses turn into "confirmations", which meansthat they've actually ordered from us, not just filled out the form.This usually happens about three or four days after the initialresponse. When this happens, the status of the response is changed toa phrase containing the word "confirm" in it (there are a few of them,but they all contain that word).So now that we've collected all this marketing intel., I need toanalyze it.I've written a parser that takes reports from various pay-per-clickcompanies and puts them into a table called PPC. Information in thiscolumn is written out as one record per search engine per keyword perday. The schema is as follows:id - a unique ID for the record in the tabledate - the date to which the information in the record appliessearchengine - the PPC engine to which the information applieskeyword - the keyword to which the information appliesclicks - the number of clicks on the applicable keyword on theapplicable search engine on the applicable day.impressions - same as clicks, but for impressionscpc - the cost per click on the applicable keyword ...avgpos - (I don't always have a value for this field) The averageposition that the keyword was shown in for the applicable keyword ...With this data in, the last step is actually analyzing the threetables for useful statistics on the various keywords, search engines,and time frames. That's the step I've been trying to complete.So what I need is a SQL call that I can run that generates a tablewith the following information:SearchEngineKeywordCost / Click - When calculating the CPC, I can't just take an averageof all the records. I need to calculate the total amount spent per day(clicks * cpc), add that up for every day, and then divide that by thenumber of total clicks. Just doing an average doesn't take intoaccount the fact that some days we'll get more clicks than others.Total Spent - # Clicks * CPC#Responses - counting the number of records in the responses table#Confirms - counting the number of records in the responses table with"confirm" in their statusTotal Spent / #ResponsesTotal Spent / #ConfirmsOh yeah, and I want to be able to order by any four of the fields inany order, narrow my selection to only those keywords that either areor contain a user-specified string, further narrow my selection toonly those records that fit other user-specified criteria for any ofthe columns in the table I'm generating, and select only the top xrecords (where x is a user-specified number). I already haveuser-controls that output the SQL for all of these things, but I needto have places in which I may put that SQL in my call.After many trials and tribulations, I've come up with the followingSQL call. Right now, its output for nearly every row is incorrect, Ithink in a large part due to the fact that the method that I'm usingto generate the number of clicks is yielding incorrect values.If you'd like to help me and you think that modifying the followingcall is easier than writing a whole new one, be my guest; if you'dprefer to write a new one, I'm game for that, too. I'm just concernedwith its working right now, and any help you can give me is greatlyappreciated.Anyway, here's the call:/*sp_dboption @dbname='NDP', @optname='Select Into', @optvalue=true;*//*Running the above might be necessary to get the "Select Into"s towork*/Drop table ResponsesPPCDrop table ConfirmPPCDrop table TempPPCSELECT Responses.[ID] as [ID], Responses.Status, PPC.SearchEngine,PPC.KeywordInto ResponsesPPCFROM Responses, PPCWHERE Responses.HitID IN(SELECT Hits.HitIDFROM HitsWHERE Hits.SearchEngine = PPC.SearchEngineAND Hits.Keyword = PPC.Keyword)SELECT ID, Status, SearchEngine, KeywordInto ConfirmPPCFROM ResponsesPPCWHERE Status LIKE "%confirm%"Order by SearchEngine, KeywordSELECT PPC.SearchEngine, PPC.Keyword,SUM(PPC.Clicks), /*I noticed that thiscolumn gives me incorrect values(I don't need it in my final report, but it's useful for debugging).For some keywords, it gives me huge numbers(e.g. 265 clicks on one word that got ~10 clicks /day over five days),and for others, it doesn't give me enough. I think this is a majorpartof what's throwing off the rest of the statistics*/Case SUM(PPC.Clicks) WHEN 0 THEN 0 ELSESUM(PPC.clicks * PPC.cpc) / SUM(PPC.Clicks) END as CPC,SUM(PPC.clicks * PPC.cpc) AS TotalCost,count(ResponsesPPC.ID) As NumResponses,Count(ConfirmPPC.ID) As Confirms,(Case Count(ResponsesPPC.ID) WHEN 0 THEN 0 ELSESUM(PPC.clicks * PPC.cpc) / count(ResponsesPPC.ID) END) ASCostPerResponse,(Case Count(ConfirmPPC.ID) WHEN 0 THEN 0 ELSESUM(PPC.clicks * PPC.cpc) / count(ConfirmPPC.ID) END) AsCostPerConfirmFROM (PPC LEFT JOIN ResponsesPPC ON PPC.SearchEngine =ResponsesPPC.SearchEngineAND PPC.Keyword = ResponsesPPC.Keyword)LEFT JOIN ConfirmPPC ON PPC.SearchEngine = ConfirmPPC.SearchEngineAND PPC.Keyword = ConfirmPPC.KeywordGROUP BY PPC.SearchEngine, PPC.KeywordOrder by PPC.keyword desc/*Drop table ResponsesPPCDrop table ConfirmPPCDrop table TempPPC*//*I don't drop them right now so I can look at them,but normally, one would drop those tables.*/Thanks a lot for your help,-Starwiz

View 4 Replies View Related

Report Model Is Generating Without Data

Feb 22, 2007

I have been generating report models for users to use with Report Builder and there is no data when they select the model. I noticed that the tables I chose did not have a primary key and when I chose a different table, with a primary key, and generated a model from it, then there was data for the user to use in Report Builder.

Is there a documented work around or will I need to set a primary key on each table?

View 3 Replies View Related

Generating Data Using Multiple Conditions

Nov 22, 2007

Hi,

I am attempting to explain my probelm again. Please read it:

I have 3 tables. CallDetail, Call and Request. The tables are populated in the following order: One row for CallDetail, One for Call and one for Request and so on.

I have to generate a UniqueNo - Per empid, Per StateNo, Per CityNo, Per CallType. The no will remain same for the same CallDetailID and ordered by the date created. However if the CallDetailId changes, the no. will increment based on the empid, Per StateNo, Per CityNo, Per CallType

For eg:

For Eg: ( Assume Call Detail id is changing for all the days)
Monday - 3 calls made for empid 1, state SA023, city 12 and call type 1 will generate a unique id 1 for all 3 calls
Tuesday - 2 calls made for empid 1, state SA023, city 12 and call type 1 will generate a unique id 2 for both calls
Wednesday - 3 calls made for emp id 1, state SA023, city 12 and call type 2 will generate a unique id 1 for 3 calls as the call type is different than the previous day for same employee
Thursday - 2 calls made for empid 2, state SA023, city 13 and call type 1 will generate unique id 1 for both the calls as combi of city and call type are different.

So the unique id has to be generated considering empid, state, city and call type, ordered by the EntryDt. EntryDt is needed because :
3 calls made for empid 1, state SA023, city 12 and call type 1 at 10/11/2007 10.00 AM will generate a unique id 1 for all 3 calls
2 calls made for empid 1, state SA023, city 12 and call type 1 at 10/11/2007 12.00 AM will generate a unique id 2 as the call was registered later.


Here is what I wrote with the help of a mod over here:




Code Block
DECLARE @Request TABLE(RequestID INT, CustomerName VARCHAR(30),
StateNo NVARCHAR(5), CityNo INT, CallID INT, UniqueNo INT)

INSERT @Request
SELECT '324234', 'Jack', 'SA023', 12, 111, Null UNION ALL
SELECT '223452', 'Tom', 'SA023', 12, 112, Null UNION ALL
SELECT '456456', 'Bobby', 'SA023', 12, 114, Null UNION ALL
SELECT '22322362', 'Guck', 'SA023', 12, 123, Null UNION ALL
SELECT '22654392', 'Luck', 'SA023', 12, 134, Null UNION ALL
SELECT '225652', 'Jim', 'SA023', 12, 143, Null UNION ALL
SELECT '126756', 'Jasm', 'SA023', 12, 145, Null UNION ALL
SELECT '786234', 'Chuck', 'SA023', 12, 154, Null UNION ALL
SELECT '66234', 'Mutuk', 'SA023', 12, 185, Null UNION ALL
SELECT '2232362', 'Buck', 'SA023', 12, 195, Null

DECLARE @Call TABLE(CallID INT, CallType INT, CallDetailID INT)
INSERT @Call
SELECT 111, 1, 12123 UNION ALL
SELECT 112, 1, 12123 UNION ALL
SELECT 114, 1, 12123 UNION ALL
SELECT 123, 2, 12123 UNION ALL
SELECT 134, 2, 12123 UNION ALL
SELECT 143, 1, 6532 UNION ALL
SELECT 145, 1, 6532 UNION ALL
SELECT 154, 1, 6532 UNION ALL
SELECT 185, 2, 6532 UNION ALL
SELECT 195, 3, 6532

DECLARE @CallDetail TABLE(CallDetailID INT, EmpID INT, EntryDt DateTime)
INSERT @CallDetail
SELECT 12123, 1, '11/5/2007 10:41:34 AM' UNION ALL
SELECT 6532, 1, '12/5/2007 12:12:34 PM'

-- Query written with help of a helpful person here
UPDATE r
SET r.UniqueNo = dt.CallGroup
FROM @Request r
JOIN @Call c
ON r.CallID = c.CallID
JOIN (SELECT
CallDetailID,
EntryDt,EmpID,
CallGroup = ROW_NUMBER() OVER (ORDER BY EntryDt )
FROM @CallDetail
) dt
ON c.CallDetailID = dt.CallDetailID
select * from @Request

OUTPUT IS
324234 Jack SA023 12 111 1
223452 Tom SA023 12 112 1
456456 Bobby SA023 12 114 1
22322362 Guck SA023 12 123 1
22654392 Luck SA023 12 134 1
225652 Jim SA023 12 143 2
126756 Jasm SA023 12 145 2
786234 Chuck SA023 12 154 2
66234 Mutuk SA023 12 185 2
2232362 Buck SA023 12 195 2

Where as it should be

324234 Jack SA023 12 111 1
223452 Tom SA023 12 112 1
456456 Bobby SA023 12 114 1
22322362 Guck SA023 12 123 1
22654392 Luck SA023 12 134 1
225652 Jim SA023 12 143 2
126756 Jasm SA023 12 145 2
786234 Chuck SA023 12 154 2
66234 Mutuk SA023 12 185 2
2232362 Buck SA023 12 195 1



as the call for Buck is of calltype 3 which was not done earlier. So the no starts from 1.

Also how to add the paritioning by empid, StateNo, Per CityNo, Per CallType and yet maintain the same unique no for the same calldetailid.
Eg: CallGroup = ROW_NUMBER() OVER (PARTITION BY empid, state, city, calltype ORDER BY EntryDt )

thanks for any help.

View 4 Replies View Related

Generating XML Data Based On The Schema

Mar 7, 2006

Hi,

i have the following requirement

Can a stored procedure in SQL Server 2005 generate XML data based on the schema, We don't prefer to manually build an xml string inside the stored proc?

Is there any SQL Server 2005 feature to do it if possible?

i appreciate your help.

Thanks,

Vaishu

View 3 Replies View Related

Generating Unique No Based On Certain Data

Oct 3, 2007

Hi,

I have the following tables :




Code Block
Create Table #Request ( [requestid] int , [customername] Varchar(30) , [stateno] nvarchar(5) , [cityno] int , Callid int, UniqueNo int);

Create Table #Call(Callid int,Calltype int,callDetailid int ) // CallType 1=New 2=Change 3=Delete

Create Table #CallDetail(callDetailId int,empid int)




The tables are populated in the following order: One row for CallDetail, One for Call and one for Request and so on

I have to generate a UniqueNo - Per empid, Per StateNo, Per CityNo, Per CallType and insert into #Request table along with the other data. How do I do this?

SAMPLE DATA



Code Block
Insert into #CallDetail(12123,1)
Insert into #CallDetail(53423,1)
Insert into #CallDetail(6532,1)
Insert into #CallDetail(62323,1)
Insert into #CallDetail(124235,1)
Insert into #CallDetail(65423,2)
Insert into #CallDetail(56234,2)
Insert into #CallDetail(2364,2)
Insert into #CallDetail(34364,2)
Insert into #CallDetail(85434,2)

Insert Into #Call(111,1,12123)
Insert Into #Call(112,1,53423)
Insert Into #Call(114,1,6532)
Insert Into #Call(123,2,62323)
Insert Into #Call(134,1,124235)
Insert Into #Call(143,2,65423)
Insert Into #Call(145,1,56234)
Insert Into #Call(154,2,2364)
Insert Into #Call(185,1,34364)
Insert Into #Call(195,1,85434)

Insert Into #request Values('324234','Jack','SA023',12,111,0);
Insert Into #request Values('223452','Tom','SA023',12,112,0);
Insert Into #request Values('456456','Bobby','SA024',12,114,0);
Insert Into #request Values('22322362','Guck','SA024',44,123,0);
Insert Into #request Values('22654392','Luck','SA023',12,134,0);
Insert Into #request Values('225652','Jim','SA055',67,143,0);
Insert Into #request Values('126756','Jasm','SA055',67,145,0);
Insert Into #request Values('786234','Chuck','SA055',67,154,0);
Insert Into #request Values('66234','Mutuk','SA059',72,185,0);
Insert Into #request Values('2232362','Buck','SA055',67,195,0);




EXPECTED OUTPUT will be (See the last column for unique nos). :



Code Block
Insert Into #request Values('324234','Jack','SA023',12,111,1);
Insert Into #request Values('223452','Tom','SA023',12,112,2);
Insert Into #request Values('456456','Bobby','SA024',12,143,1); // Calltype = 1 empid= 1, but state is different, hence unique id is 1
Insert Into #request Values('22322362','Guck','SA024',44,114,1);
Insert Into #request Values('22654392','Luck','SA023',12,123,3);
Insert Into #request Values('225652','Jim','SA055',67,143,1);
Insert Into #request Values('126756','Jasm','SA023',69,134,1);
Insert Into #request Values('786234','Chuck','SA023',72,145,2);
Insert Into #request Values('66234','Mutuk','SA059',72,185,1);
Insert Into #request Values('2232362','Buck','SA055',67,195,2);





Please note that this will not be run as a batch query, but the no. has to be generated and inserted into #record table in realtime. I have given bulk of records for understanding of the problem

Plz help. I am stuck from 2 days on this :

Vidkshi

View 8 Replies View Related

Trying To Include Data In Generating Script For SQL 2005

Jun 13, 2007

 Hi: I have SQL Server 2005 Express edition and I am trying to generate a script that someone can take and import into the full version of SQL Server.  Using the Generate Scripts Option, I have been able to generate scripts for the various SQL statements that I created - but cannot get it so that the data is included.  I'm new to this and would appreciate any help.  I have a populated database that I would also like to transfer to the new server.Any help greatly appreciated.Roger Swetnam 

View 2 Replies View Related

Generating Full Script Tables And Data?

Feb 8, 2006

hi, I'm using sql server 2005 standard, and I want to be able to move my local database to another server, but I can't figure out how to script the database and the data so that I can just run one script to move the whole database. this can be done right? I can't imagine that such an obiviously necessary tool would be intentionally left out, so I'm figuring that I'm just a doofus and don't know where the option is...

can anyone help? thank you!
-SelArom

View 2 Replies View Related

Data Warehousing :: Generating STATISTICS (Automation)

Jul 21, 2015

Is it possible to write a SP (Automate) to generate STATISTICS on any database and then use the output to create the stats on that database.

I ran the tuning adviser and it suggested indexes with lot of STATISTICS on the dev environment. This dev environment is replicated in several other environment with data size in these environment varying. I would  like to know if I can create a SP which generates STATISTICS information pertaining to specific database environment for the query in question for tuning. 

View 9 Replies View Related

Error When Generating Data Source Model

Mar 20, 2008

When I attempt to generate a datasource model I get the following error messages:
------------------------------------------------
More than one item in the Entity 'Customer' has the
name 'Customer Merge Custs'. Item names must be unique
among immediate siblings. (DuplicateItemName)

More than one Field in the Entity 'Customer' has the
name 'Customer Merge Custs'. Field names must be
unique within an Entity. (DuplicateFieldName)

More than one item in the Entity 'Pricing Service Layout
Detail' has the name 'Pricing Service
Extensions'. Item names must be unique among immediate
siblings. (DuplicateItemName)

More than one Field in the Entity 'Pricing Service Layout
Detail' has the name 'Pricing Service
Extensions'. Field names must be unique within an Entity.
(DuplicateFieldName)
---------------------------------------------------

Examining any of the above tables in SQL Server Management Studio does not reveal any duplicate column names. In fact, 'Customer_Merge_Custs' does not appear to be a column in 'Customer' nor does 'Pricing_Service_Extensions' appear in 'Pricing_Service_Layout_Detail'.

As an experiment, deleting the table 'Pricing_Service_Extensions' and regenerating did make the two associated messages go away.

Steve P.

View 3 Replies View Related

Generating Data In An Order Per Data Row

Dec 7, 2007

Title is probably poorly worded

Say I have a table setup like this:


Code:

AccountID | GeneratedDesc | Col1 | Col2 | Col3 | Order
-------------------------------------------
1|| Data1 | Data2 | Data3 | 1,2,3
2|| Data1 | Data2 | Data3 | 1,3,2
3|| Data1 | Data2 | Data3 | 2,3,1
1|| Data1 | Data2 | Data3 | 1,2,3



Basically, I want to set GeneratedDesc = Data1 + ' ' + Data2 + ' ' + Data3 where an account sets the order 1,2,3

GeneratedDesc = Data2 + ' ' + Data3 + ' ' + Data1 where an account sets the order 2,3,1

Basically, The Generated Description is set in an order that is chosen by the Account.

I am not sure how to go about doing this, outside of dynamically generating the query and looping throughout all the rows in the table, which, i think for large amounts of data, can get expensive. I don't think creating a query for each combination would be good either (in this case, 6 combinations, but for larger order sets, such as 6, can get quite alot of queries).

any ideas? (not sure if this makes sense to anyone)

View 2 Replies View Related

RS Pick List Not Generating From Data Set With Stored Procedure

Apr 1, 2008

I have a stored procedure that is pulling 3 parameters: @user_id, @, begin_date and @end_date. The parameters are setup in the 'parameters' tab of the data set, and also the 'report parameters', however, when I go to run report, I get textbox for user_id, instead of a drop down with pick list.

I tried creating a separate dataset to bring in user_id's only and manually create a parameter for it in 'report parameters'. I then get a drop down box with repeating data, and when I run the report, I get back all user_id's instead of the one I chose.

I'm finding the parameters are the most difficult concept within RS. Does anyone know I can make this work?

Thanks!

View 1 Replies View Related

Appending Data From Database 1 To Database 2 (live Into Dev Env)

Feb 1, 2005

have 2 databases in sql server 2000

Live
Dev

I need to append all the data from LIVE into DEV environment. I have tried using MS Access (linking tables & importing tables and running APPEND query to update the rows from LIVE to DEV but PK & FK is causing problems as some data will have the same ID's....

Could I use DTS--Access wizard in SQL Server.

What is the best option to use?

Thanks all in advance

View 2 Replies View Related

Meta Data Help Needed[:(]

Aug 1, 2007

Hi Guys,
I have a DataBase in which I have several Tables.
What I want is an SP or Query which takes as its parameter the "tablename".
The Output Should be a having three fields only.
Field name, DataType Of the Field, Length of the DataType.
For Example
Suppose the StoredProcedure Name is "SP_GetTables" 
if i have a table named "tbl_Users" with fields
UserName varchar(50)
UserPass varchar(20)
UserAge int
UserStatus bit
In my program side if I pass the parameter as "tbl_Users" to the StoredProcedure SP_Users,
I should get the O/P as
Field Name    DataType  Length
UserName      varchar      50
UserPass       varchar      20
UserAge         int
UserStatus     bit
Regards,
Naveen.
 

View 3 Replies View Related







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