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

Query self relating table

I have a self relating table that I need to query in the following way.TableID, ParentId, Format, Qtysample records1, Null, A4, 4 2,1, B/W,  4 3,1, Duplex, 24,Null, A3, 1 5,4, Color, 1somehow I need to...

View Article


Insert Value That is In Table Being Inserted Into and Distinct Values from...

I'll try to show this through an example. I have 2 tables. tblMain is the main table that will be inserted into and tblValues contains the values that will be inserted. The 2 tables are joined on an ID...

View Article


Query many databases at the same time

Hi,I have 44 identical databases and need to query them all at the same time and calculate an average of two columns. I have only read access to the databases so I cannot create any objects in the...

View Article

The requested operation could not be performed because OLE DB provider...

I am getting the following error when attempting to INSERT the results of an "EXEC(@MDXQuery) at SSAS LinkedServer":The requested operation could not be performed because OLE DB provider "MSOLAP" for...

View Article

Use Select Query Result as a Function Argument

I have a larger query that consists of a lot of parenthetical SELECT statements. Some of these parenthetical SELECT statements are results of table-based function results. To make things briefer, here...

View Article


Help with SQL query

I have a query where I use 8 subqueries to return the data that I need. I am guessing this is not optimal and is probably horrible on performance. Here is my scenario simplified:Table WALL and table...

View Article

Need to find all the variable list within the procedure with there data type...

Need to find all the variable list within the procedure with there data type and assigned values.EFor e.g.procedure have 2 variables @a int ,@b varchar(100)set @a= id from t1set @b=name from t1the i...

View Article

Multi-Level Transaction

Hi, I've read about multi-level transactions, but I could not find a proper example code. Could anyone give me a simple and real example SQL code which takes advantage of multi-level transaction in...

View Article


How to get last 3 months sales

Hi,Lets say i have a query likeselect sales from test where MONTH(GETDATE())>3 it gives me the past 3 months sales as we are in 6th month, but i want to have something in the where clause which can...

View Article


Need Max field

Currently field is convert(char(10),SgeEffStartDate,111)But I get duplicate rows.  I only want the max date.  How can I do that?

View Article

Simultaneously inserting data in to T1 and T2

Hello,pls, how to insert new row into T1 and T2 , e.g. PIN, at the same time. In T1, PIN column is PK while, in T2, it is not  (allow null = yes)?My wish is to insert PIN into T1(of course via App...

View Article

xp_cmdshell to Copy Document based on ID

Hi all,Is it possible to use xp_cmdshell to copy a document on the server to a shared folder using the code for the document.My example is - A sql table with Code and FileLocation. I know the codes for...

View Article

How to PIVOT Data by the Day

I have a scenario where I need to represent data being returned by converting the Day column from being in a row format to being in a column format. I believe that PIVOT can be used here but I've been...

View Article


Conversion failed when converting date and/or time from character string

Hi All,I am trying to run the following query and it gives me the errordeclare @StartDate date, @EndDate date set @StartDate = dateadd(month, datediff(month, '19000101', CURRENT_TIMESTAMP) - 3,...

View Article

Dynamic queries / value in stored procedure risks of sql injection?

Trying to understand dynamic query / value in stored procedure. Can someone direct me to a good article that explains how sql injection / other potential risks are possible in stored procedures.For...

View Article


SQL query to store float values in french culture.

Here is how my requirement goes..I have an application where users can store float values into the SQL server. Here float values are period(.) based. I have now started supporting the users who use the...

View Article

suser_name override

Hi.  We run 2012 enterprise.  I think this is the best forum in which to post this question in spite of c# and rs involvement.We use data driven security based on suser_name to determine which plant...

View Article


Making a SUM value 0

I have a query and those items that return null I need to make them a 0 and add the unit to it as well (g, mL) which comes from the DefaultContainerSizeUnit table. Any help is greatly appreciatedHere...

View Article

Filling gaps when calculate running total

Hello Friends,i have a script that calculate running total,but i have gaps between dates.i had some solutions to resolve this issue but it did not perform well.because my source table has over milllion...

View Article

Removing accents from names

firstname=dbo.dsi_fnRemoveChars('''.,/-#''',replace(Upper(pnamefirst),' ','')),How do I add in to remove accents as well from letters?

View Article
Browsing all 23857 articles
Browse latest View live


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