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

Showing Top 3 within a multiple count query

Within a query that contains multiple counts based on a combination of data elements, is there a way to display in the results the top 3 records for each count?  Desired Output and  Current Query text...

View Article


SQL Procedure working when run manually, not running from sql server agent

I have a procedure that runs fine using the execute command in SSMS, however putting the same command in a job gives the following error.line 9, character 9, unexpected end of input The code takes a...

View Article


This part of query is taking long time to run, its about 40 minutes. Can...

------Load Dataset into Temp table--------------- SELECT z.SYSTEMNAME --,Case when ZXC.[Subsystem Name] <> 'NULL' Then zxc.[SubSystem Name] --else NULL --End AS SubSystemName , CASE WHEN...

View Article

Querying a clustered server using a four-part name

I have a cluster, call it CLUSTERA, containing SERVER1 and SERVER2. Then I have some other servers which don't need names for the purposes of my question here. I am trying to build queries across these...

View Article

Copy of specific records and get new rows but how to make sure relationship...

Party Relationship Rela ID master/Duplicate TypeRelationshipID 1 M A 2 M A 3 M B 4 D A 5 D C 6 M A 7 M C Party Relationship Category Rela ID CategoryID 1 3 2 5 3 66 4 14 5 15 6 17 7 18 Party...

View Article


Image may be NSFW.
Clik here to view.

Creating a windows cluster 2012 for sql server 2012 clustered installation

Hello,I am trying to create a windows cluster for sql server 2012 clustering on windows server 2012 R2  standard edition-64bit OSwhen i perform the test after adding the cluster nodes i get this...

View Article

EF6 Code First: Many to Many Self referencing relationship

Hi,Could any one show me an example for many to many self referencing? The scenario is that I have a user table that will contains collection of users as friends.Thanks,Bo

View Article

Performance - INNER JOINT to the same table

HI!Which of the next structures is most efficient?1- SELECT DISTINCT a.ID FROM table a     inner join table b    on a.column1 = b.column1  and a.column2 = b.column2   and a.ID <> b.IDor2- SELECT...

View Article


Selecting Non repeatable random records

HI all, I have 20 records in table. I want to get a random single  record from that table.And the main thing isif i having 20 records 1st time i'm getting a random record.the upcoming execution result...

View Article


Help in query please

Hi,I have to check data in ctcode_desc to find the wrong data. The logic of the input in ctcode_desc is 'number, single space, - sign, single space, text'.The logic of the input in ctcode is...

View Article

Inserting Data to a temporary table

Hi,This may sound strange, but I see code that inserts data to a temporary table, which sources from the same temporary table. The code looks like this:-- Some code that initially inserts data to...

View Article

Using nested IF condition

I am making a vb.net project using SQL-SERVER at back end. Since SQL queries are lengthy i have to use STORED-PROCEDURE.. Following condition have to be tested in T-SQL. But my program frequently gives...

View Article

How to get values from XML in this situation

Dear All,<H><G N="a" sr="1" Visible="True"  Dc="a1">          <Co N="abc1" sr="1" Visible="True"  Dc="abc11" />          <Co N="abc2" sr="2" Visible="True" Dc="abc22"...

View Article


sql agent

I have 100 SQL Server agent jobs, each job has different TSQL Statements , how can you find a job that is having this statement ‘ Select count(*) from dbo.test’ ?

View Article

Decision Factor: Benefits of Computed Columns

Any computed column can be computed in a query. So how do you decide when to design a computed column?In the following BOL example the hard-wired expression may make it a good candidate for a...

View Article


bcp export question

I need to bcp export 3 large tables from our prod sql server.  How does bcp manage transactions on the source server when bulk exporting?  Does it hold one long running transaction?  Is this...

View Article

finding number of records in a table without count *

You have ten tables in database and all have cluster indexes on them, If I ask you to give me the total row number in each table without using count(*) from table, which table can help you to find...

View Article


Image may be NSFW.
Clik here to view.

Concatenate in sql server

Hello,i have a table which contain two field customer and phonenumber and following record.Now i want a query for customer-wise  phone number with Concatenating . similiar like attached image.i am...

View Article

Transfer data from one database to another without identities but keep the...

Hi,I need to transfer data from one database to another database (both are identical databases). 1. Not transferring identity columns (primary keys). the destination table might have the same key.2....

View Article

How can I update a particular column in a 7 million record table, where it...

I am designing a table, for which I am loading the data into my table from different tables by giving joins. But I have Status column, for which I have about 16 different statuses from different...

View Article
Browsing all 23857 articles
Browse latest View live


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