[T-SQL] building a dataset ! |
- building a dataset !
- expression in derived column issue
- Select full month number (with 0)
- Compare list of tables in two Databases from SSMS
- Guidance on table valued types.
- Need to create a Scalar Valued Function
- Compare the rowcount
Posted: 28 Feb 2013 07:14 PM PST Hi,I have 6 tables MustHave_...... , and a table project.i wanna display in ssrs a table which contain for each project, the percentage for each must have ! should i use a join or a union for my 7 tables ?thank you |
expression in derived column issue Posted: 28 Feb 2013 09:44 PM PST I want to cretaed new column in derived column with default string valuve likeColumn name Expression TableName FactFDDCellQHourlyPegEricsson1I have tried in many ways converting into sting and text but it showing an error, Plz any one help me to get out of this. |
Select full month number (with 0) Posted: 28 Feb 2013 05:38 PM PST Hi,I use[code="sql"]DATEPART(month, myDate)[/code]or[code="sql"]MONTH(myDate)[/code]the resut is: 2 (if myDate is 2013.02.03). I would like return: 02Do you have any solution for this?Thans! |
Compare list of tables in two Databases from SSMS Posted: 28 Feb 2013 04:15 PM PST Hi SQL Gurus,Need to do some cleansing work this morning and I was wondering If I can get help here in the forum.Is there a way we can compare the list of 1) Tables2) Views3) SPsin two different Databases on same server. I would use a 3rd party tool in case there is no way at all from SSMS.The key here is that I don't want to compare the Data in tables, just checking table names would do.So what I want isSelect <List of tables> in DB1EXCEPTSELECT <List of tables> in DB2Same for view and SP.Any Ideas, suggestions ? Thanks a lot in advance. |
Guidance on table valued types. Posted: 28 Feb 2013 06:02 AM PST We have 1 table valued parameter (tvp) coming to GetXXX stored procedures. It contains only 1 column of type uniqueidentifier. Currently, it does not have any index on it. For performance improvement, I was thinking of adding a primary key as clustered index on it. My initial testing showed if there less than 100 records in that tvp then it actually performs worse than the older one which doesn't have any index on it. I was hoping that it would perform same if not better for smaller datasets. Does anybody know if I'm missing anything here.Thanks in advance.Regards,Mayur |
Need to create a Scalar Valued Function Posted: 28 Feb 2013 03:05 AM PST Hi ,I need to write a Scalar-valued function ( I guess) to get the highest status for each member on a given day if there are more than one status entered for that particular member on that particular day.Below is the very simple scenario:-- 1. Create Agent Status HistoryGOCREATE TABLE [dbo].[AgentStatusHistory]( [AgentID] [int] NOT NULL, [QualifyDate] [datetime] NULL, [Status] [varchar] (10)) ON [PRIMARY]GO-- 2. INSERT some data into AgentStatusHistory tableGOINSERT INTO dbo.AgentStatusHistory (AgentID, QualifyDate, Status)SELECT 101, '2010-02-01 00:00:00', 'LOW'UNION ALLSELECT 101, '2011-05-01 00:00:00', 'MEDIUM'UNION ALLSELECT 101, '2011-05-01 00:00:00', 'HIGH'UNION ALLSELECT 102, '2012-22-25 00:00:00', 'LOW'UNION ALLSELECT 102, '2012-22-25 00:00:00', 'MEDIUM'UNION ALLSELECT 102, '2012-22-25 00:00:00', 'HIGH'GOFrom the above example, if I execute the below SQL query..SELECT * FROM dbo.AgentStatusHistoryORDER BY AgentID, QualifyDate;here is what I need to see in the result set…• AgentID, QualifyDate, Status• 101, '2010-05-01 00:00:00', 'HIGH'• 101, '201-02-01 00:00:00', 'LOW'• 102, '2012-22-25 00:00:00', 'HIGH' |
Posted: 28 Feb 2013 01:06 AM PST hello World,I have table with date and rowcount like below. Time stamp Row Count2013-02-28 10:53:50.283 12112013-02-28 11:53:50.283 12122013-02-28 12:53:50.283 1213 2013-02-28 13:53:50.283 12132013-02-28 14:53:50.283 1213I am running the below command to retrive the information.select getdate(), 'Row Count' = count(*) from dba_backuplocationNow, i have to create a table with two columns Timestamp & Row count (say the table name is Rowcount_monitor) and insert the rowcount values every hour using a sql server job. ( If we put my requiremnt is stored procedure and get that executed through job).Requiremnt :I have to monitor the table and compare the last three hours of rowconut and if the rowcount is same then i have send an database mail saying rowcount did not change from last three hours. We can use the above table as example where the last three rowcount did not change. Also we have have to delete the records if they are two days old.Can someone help on this immediately. |
You are subscribed to email updates from SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8) To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment