xml path help required
I have query - I'm sorry, i have not specified exact tables / field names. I just want to how do I get my required out put.select empid, ename, cast ('<eventdata>' + '<dataitem>' +...
View Articlegetdate() and getutcdate()
HI, I'm just wondering to know the difference between belowSelect getdate() 2014-02-21 11:43:08.607 select GETUTCDATE() 2014-02-21 16:43:08.607Why is the result is different and what is the difference...
View ArticleCASE in JOIN CONDITION
Hi,I have written below sample code for a join condition. Please let me know, if there is a good way to write it.SELECT * FROM dbo.DETAIL AS DET WITH(NOLOCK)LEFT JOIN #Data AS Acct WITH(NOLOCK) ON...
View ArticleFraction to number TSQL conversion
I have a database column, "my_value", that is a NVARCHAR data type.I would like to convert that "my_value" from i.e. 1/4 to .25 Is there a function or series of functions I can use to get this done?...
View ArticleHelp with query
I need help with a SQL query. The below query if run on a 2008 R2 Instance gives the output of 10.50.4276.0select (SERVERPROPERTY('productversion'))What do I do if I want the output to be limited to...
View ArticleNeed a PIVOT-like solution
I have a stored procedure based on a primary table that has multiple rows for different dates within a year. I want the result set to display all dates as separate columns. Normally there are no more...
View ArticleCURSOR vs. CTE
Good morning and a happy Monday to all.My mind is currently dribbling out of my ears and making a mess on my desk as I look at a cursor that I'm trying to optimize.My thought is that I should replace...
View ArticleRrecursive foreign keys
I need hlep for one query.I have on DB where we have 350+ tables. I just want to get the list of tables which have recursive foregin keys.Like Table A Link to Table B and Table B Link to Table A.Thanks
View ArticleCould I get some help with my function and query?
I wrote a function that calculates the discount price of an item:IF OBJECT_ID('fnDiscountPrice') IS NOT NULL DROP FUNCTION fnDiscountPrice; GO CREATE FUNCTION fnDiscountPrice (@ItemID int = 0) RETURNS...
View ArticleCreating an Instead of Insert trigger that blocks certain values
Hi guys, I'd like to create an INSTEAD OF trigger for the Person.Address table in AdventureWorks so that anytime someone inserts a value that does not begin with a number in AddressLine1 column, it...
View ArticleAdd comparison to roll back transaction?
I would like to add some logic to the transaction below that would check the number of records inserted in the first table and deleted in the second one. These quantities should be the same and a...
View ArticleNeed Your Helpfull Suggestions
Hello All,This is Raj, I Am fresher in SQL Developer just done with Training, I am Not So Confident in T-SQL, Friends Can Anyone share me links for Practise Tests or Sample Queries on T-SQL...
View ArticleOne Clustered Index
Why only one clustered Index in SQL Server? Can you please explain in more detail?
View ArticleTree Query Problem
I've problem with tree query where if a level > 3 the result for top level is incorrect. Here's the query with correct result where level of depth just 3 level :--select *from tblBOMStructed DECLARE...
View ArticleCan I pass a table function parameter like this?
This works. Notice I am passing the required table function parameter using the declared variable.DECLARE @Date DATE = '2014-02-21' SELECT h.*, i.SomeColumn FROM SomeTable h LEFT OUTER JOIN...
View ArticleDoes derived table use where clause fillters inside
dear all.Table "A" has two cols aid and col1 , aid is pk.Table "B" has two cols bid , aid , and colb .followin query can be formulated in other ways ,but i wanted to ask something about query...
View Articlecan seting identity with pk create any problem in any situation.
Dear all, I have to just insert into a table ,which is history table , so i used identity with pk .and any body can insert into that table. That table can be on other database.and people can...
View ArticleError converting data type nvarchar to bigint.
hi alli used this t-sql codesSELECT PAH.TypeRef,PAH.ProductActionHeaderNum,PAH.ProductActionHeaderDate,PAH.AccountDetailRef ,AD.AccountDeatil ,PAH.StorageRef ,S.StoragesName...
View ArticleThe Query Needs to populate Most recent Data and time of the values Captured...
Hi Friends, Already My Table has Callback1DateTime, Callback2DateTime, Callback3DateTime, Callback4DateTime and Callback5DateTimeI Need to add ‘Latest Callback’ that’s a calculated field based on...
View ArticleKalman, please do not move this thread.
I Posted a question on getting the opinion of Forum users Of T-SQL. But unfortunately, Kalman moved it.It may be to get me more appropriate reply or something else. But here, am looking for the forum...
View Article