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

Creating ; seperated data

I have a table that has a bunch of ids and email addresses.  I want to query the table and return the email addresses separated by semi colon so I can feed it into an email.  Is there an easy way to to...

View Article


Need to exclude weekends from two dates

I'm trying to figure out how to exclude weekends from the DATEDIFF function I have on the SELECT statement below. This code works exactly how I want it to work but I'm having trouble trying to figure...

View Article


Image may be NSFW.
Clik here to view.

Execution plan is showing missing index even index presents

Hi, I'm using SQL Server 2012 . I execute the query with actual execution plan and it showed a missing index details . I have added index like this ..CREATE NONCLUSTERED INDEX [Index_TaskMaster_2] ON...

View Article

Image may be NSFW.
Clik here to view.

How to remove Table Spool(Eager Spool) from query plan of a function

Hi all.Thanks for your time and expertise.My question is about Table Spool operatorI have spent numerous hours reading all suggested topics, including topics when suggested during creation of this...

View Article

SELECT on year month only in '2013-Jan' format?

Hi,is there a way of selecting on year month only in sql when the format of the date passed is '2013-Jan'. I'm not sure at the moment if I have any control of the date format passed so wanted to...

View Article


How to transform data from row into column

Hi All, May any one help me in query for the below scenerio :   I have data like this in the table :IntRecpieID          strName           intMealtypeID          Total  100'A'  120  101'B'  2...

View Article

REPLACE statement in SQL

How do I write a SQL statement to drop the last two characters from a varchar data field?  I've tried REPLACE but it did not change a thing.

View Article

SQL Like Operator query

HiI would like to extract data with criteria between 'J09' and 'J18'. These are hierarichical disease codes. Therefore you can have J091 to J189. This is my query below.Select * from...

View Article


Report and more summary value

I need to build a report to show per each product (obj_id) number of sales ( a simple COUNT will do), total income from the sales and number of units sold (quantity). The following works OK, but I use...

View Article


How to pivot using pivot clause of sqlserver 2005 for three values

Dear all            Is it possible to formulate the query using pivote clause of sqlserver 2005.( Table name is) BridgeHawra--------ReportDate,                 , Pole, DiameterCost,Flag,OuterDiaCost01...

View Article

The First execution of a Stored Proc shows a delay between SP:StmtStarting...

We experience a performanceproblem with some of our Stored Procedures. SQL Server is "Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64)"Situation: SQL Server Proc1 executes some SQL Statement and...

View Article

Looping with cursor

Beleive that I can use cursors to loop though a list.I have a table that lists table names which I want to copy from one db to another.  The code I am trying is as follows:USE Finance Declare @ID int...

View Article

unexpected results using XP_DIRTREE

I am working on a procedure that will check directories using `xp_DirTree` to confirm that the correct number of files have been generated by an earlier process.Unfortunately my query (the last part)...

View Article


Exclude fields from a report using RIGHT() command

Hello,I have an audit table that I am running queries against to ensure there is not data loss.  All changes in our database get logged in this audit table.  For the purposes of my query I am trying to...

View Article

table value function vs sp that return a dataset

The conventional wisdom seems to be that you use stored procedure to do something in a database, but when you need to return a dataset that involves procedural logic, then you should use a table value...

View Article


Stored Procedure Parameters - Setting a default value

Using SQL 2005, 2008, 2012This should be easy, but think that I am making it hard. Below is the stored procedure that I want to call. If I want to pass a 'N' to @SearchDBsFlag how can I retain the...

View Article

Not understanding foreign key error

Hello all,  I have a problem that I think is a little odd. First off i have three tables one is considered main, one with data and another one to copy the data too. Now i know about forgien key error...

View Article


First value of multiple subsets

I have an interesting problem.  I need to query a list of customers, and retrieve the first row in the latest subset.  I have created a version, but it is way to complex.Example:Cust_Num     Date...

View Article

ddl trigger to track permission change in database

Hi,How can I create a DDL trigger to log any permission change in a database?thanksoldmandba

View Article

SQL Query to find the Delta between 2 rows

Can the below be possible? If so can you help me writing a dynamic SQL Query to do so…I have data in spreadsheet which is pulled off from the database (data from more than one table with joins); send...

View Article
Browsing all 23857 articles
Browse latest View live


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