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

Filter TOP query so that a result cannot be in the top if the column value is...

Hi, Any help would be appreciated. I have a query that is the top(5) but I want them to be distinct on only one column value, not on the entire row. Any help would be really appreciated.Regards,   Seamus

View Article


String value is giving different values

Hi,When I run the string equals it just works fine but if I give date by converting it to a char and give it in < or < it gives random answers.

View Article


Hierarchy with calculation

Hi I need to Return values with hierachy sum. I have provided the tables with data and result expected below============ CREATE TABLE ============ CREATE TABLE [dbo].[Travel_Master]( [Load_Id] [int]...

View Article

Help in the query please

Hi, How I can use SELECT statement to avoid the data (1,2,3,4,5,6,7,8) in the result but I don't want to USE 'NOT IN' function. I want to use greater than and less than operator because data is huge....

View Article

Show parent and 1st child

I have data where i need to Show only Parent and 1st Child==================== CREATE TABLES ==================== CREATE TABLE [dbo].[Travel_Master]( [Load_Id] [int] NULL, [Mode_Id] [nchar](2) NULL,...

View Article


Database mail user not sending emails

Hi allI have a user (User1) which is employed to send an email to an internal address when an event is triggered.  It's DB permissions are as follows:StorageDB - dbOwnermsdb DB -...

View Article

Mathematical and statistical challenge for developers

Hi guys, a mats/statistical question. I've been asked to make a calculation in SQL (it's more fun that really job..to be honest it's only fun...anyway..) with a situation like this:38 events (...

View Article

Sorting Order

INSERT INTO tbltmp VALUES (769,'BBB','2011-06-30','2011-09-30'), (769,'BBB','2011-12-31','2012-03-31'), (769,'BBB','2012-03-31','2012-06-30') SELECT * FROM tbltmp EXPECTED OUTPUT: 769 BBB 2011-06-30...

View Article


Pivot Query

Hi ALL , I have Data in below Format in my SQl Server  table Month Price Category  Days Jan 12 Average 40 Jan 13 Non 50 jan 12 Required 60 Jan 34 Average 33 Jan 56 Non 44 Jan 54 Required 60 Jan 34...

View Article


Copy table from one server to another

I want to copy a table and its data from a databse on one server to a database on a second server (creating a new table).  What is the best way to do this?  If there is a utility to do this, please...

View Article

identify default min value

hi all,i have a table call 'transaction' and structure is like bellow TransactionDateTime2012-08-10 22:00:00.0002014-01-01 20:15:00.0002013-01-01 11:00:00.0001753-01-01 00:00:00.000if you look at the...

View Article

Batches Updates VS Regular Updates

Hi All,What is the difference between Regular Update and Batches wise updates in SQL SeverThanksCMK...

View Article

Eliminating an Inner Query when using UNPIVOT

In the following query, I am attempting to UNPIVOT a number of different phone / fax numbers into a single column named 'PhoneNum'.I haven't used UNPIVOT before, and I'm trying to understand a couple...

View Article


Please help me to write the logic for this critical requirement in TSQL!

Hi,  I have a critical requirement. Please help me to resolve this. Below are the DDLs. Create table Student ( StudentName varchar(50),StudentID bit,InCricket bit,InFootball bit, InHockey bit,InMaths...

View Article

Is this a good use of a CTE?

-- THE CODE OUTLINE OF A CTE(COMMON TABLE EXPRESSION) -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- WITH expression_name [ ( column_name [,...n] ) ] -- AS -- ( CTE_query_definition ) --...

View Article


SQL query to get last 10 records in the table?

Hi,Can anyone tell me the SQL query to get last 10 records in the table?Thanks!! MCP

View Article

Image may be NSFW.
Clik here to view.

Unable to discover Why No Join Predicate

Please help me, I have this query: select pc.Val,        PC2.Valstring as valstring,        pc.ValString as MessageType,        pc2.Val as Port from dbo.tblproperty            p with(nolock) inner join...

View Article


Recursive sql

I need help please.I have a table with payments. I need to check for each idno if he has payments for a certain year that exceeds the total amount allowed. In my example the total amount allowed for...

View Article

Using newest version of SQL Management Studio with SQL 2008?

I basically use SQL Management Studio 2008 to write SCCM SQL queries. The DB version on our SCCM servers is 2008 (not R2). Is it possible to use newer versions of the Studio with SQL 2008, and get some...

View Article

Locking levels

I am inserting 5000 rows from working table to main table?will the sql server lock my main table row by row and or page level or table level?how do i know what factor determine what level locking does...

View Article
Browsing all 23857 articles
Browse latest View live


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