Quantcast
Channel: Transact-SQL forum
Browsing all 23857 articles
Browse latest View live

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 Article


getdate() 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 Article


CASE 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 Article

Fraction 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 Article

Help 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 Article


Need 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 Article

CURSOR 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 Article

Rrecursive 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 Article


Could 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 Article


Creating 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 Article

Add 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 Article

Need 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 Article

One Clustered Index

Why only one clustered Index in SQL Server? Can you please explain in more detail?

View Article


Tree 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 Article

Can 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 Article


Does 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 Article

can 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 Article


Error 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 Article

The 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 Article

Kalman, 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
Browsing all 23857 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>