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

Image may be NSFW.
Clik here to view.

TSQL Help SQL Server 2008 R2

Hi, I'm trying to figure out how to write the TSQL that produces the results in the yellow column of the attached picture.  I basically need to translate the formula in column H into TSQL. I've spent...

View Article


How can I get the cumulative sum of a field in a table

For Eg. I have a table like gias given below:Name                  Amount------------------------------aaa                       10bbb                      20 and I want an output like one given below...

View Article


In group by some times we need to put max or min .

Dear all,In following query select  tid, max(colint), min(colvarchar),count(*) from t group by tidif i have duplicate records on tid, i want to know count of them and want to display their cols...

View Article

Subquery to calculate Monthly Available Amount

Hi folks,I have written a query that gives me monthly budget (which is nothing but total budget/12).select H.Budheadid,Budgetname,BudDetailID,totalBudget,(totalBudget/12) as TotalBudgetJan,...

View Article

having null on index col is good or empty is good.

Dear all,             I have a col , which has few percentage of null, i want to create index on the col.is it good have empty in place of null or null better than empty for an index?yours sincerely

View Article


sql query

I'm trying to join to tables and get counts but not sure if this is right.Table1 has columns -  name, model, os, memory, locationTable2 has columns -  location, descriptionThis is output I'm trying to...

View Article

How does this UPDATE update multiple rows?

For the UPDATE in the following script, what values are selected to update Table2? For example, for a row in Table2 (ie. 'NY') there are several rows in Table1 that can be used for the...

View Article

Find the service which controls agent on job server and find out the login...

How do I find the service that's controlling my SQL server agent on the job server and find out the login it's using ? Is there a query for this ?

View Article


Special join or other way

Hi Forum,I am having a problem with incosistent data of two columns with semicolon separated values. Column A and column B should have the exact same number of elements, which is not always the case.In...

View Article


BCP codepage output issue SQL2008R2 x64

Hi chaps / chapesses,I've been playing with BCP using SQL2008R2x64 and have run into an issue. Essentially there is a system I have no control over whatsoever but need to get extracts off. Just about...

View Article

Any Better way to write this code

Hello Professionals, My code in CTE below is taking more than 5 min to return 500 records. Is there any better way to write this piece of code. Str before a column name indicates its a varchar field...

View Article

How do I find out if Sql server Agent's login has rights to a DB?

How do I find out if the SQL server Agent's login has rights to the target DB, that is the DB on which I will be executing a query ? Is there a query for this ?Thanks.

View Article

Alternative to Case Expression

I have a query which has 2 levels to it, Matter level which is the highest level and Claimant level where there could be multiple to one Matter level (there is only ever one Matter level)Here is a...

View Article


String Function that search for URL's in a VARCHAR(nText) Column.

I have the following situation:I have a column in a table with the DataType VarChar(nText), in that column users entera URL like i.e. http://www.mycomanyname.com or any other URL of course.The thing is...

View Article

Only functions and extended stored procedures can be executed from within a...

Hi, l've created an function [GSM].[KPIAging], and test it in studio by substitule declare value, i.e.DECLARE @sCellName VARCHAR(8)DECLARE @dDate DATETIMESET @sCellName = "CELL1M_1"SET @dDate =...

View Article


Joining to an excel spreadsheet?

Good Morning,Does anybody know how I can join an excel spreadsheet to a table in my sql database?My SQL Table is called pmh.vwTOPASInpatientsMy Excel File is called PMH Transfers Unsuccessful Transfers...

View Article

TSQL Search and Extract Different Activity Sequences in a given set of data

Hello,I have the following tables1) EVENT_NAMES (EVENT_NAME_ID, EVENT_NAME)1 PM 2 PM WASH 3 Backlog 2) EVENT_NAME_SEQUENCE(SeqParentKey, Event_Name_ID,Seqorder)Data looks like below1  2   1 1  1   2 1...

View Article


IF ELSE vs CASE WHEN

Can someone explain why the first statement works, but the second one generates an error if myfunc() does not exist? 1) if exists(select name from sysobjects where name = 'myfunc') select...

View Article

Available Time Slot between two dates

maybe its too simple or maybe its too complicated, but I cant find any solution around this problem. Or maybe i just spent too much time looking at the screen trying to solve it, but now i am...

View Article

Convert table help

Hi all, I have the following table which I need to convert DECLARE @Class TABLE (  ID int,   Line1 int,   Line1Percentage int,  Line2 int,   Line2Percentage int,   Line3 int,   Line3Percentage int  )...

View Article
Browsing all 23857 articles
Browse latest View live


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