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

Image may be NSFW.
Clik here to view.

Traversing in a loop weekly

Hi,I have a loop in which I would like to Select query on weekly basis starting from the last date, essentially traversing backwards week-by-week.  For example the table below represents the sample...

View Article


Comma separated output into columns

Hi,I've the following Query :select ParameterValue FROM Event.vEvent  join event.vEventParameter on event.vEventParameter.EventOriginId=event.vEvent.EventOriginId where EventNumber=0which gives the...

View Article


Help in the query of Grouping

Hi, Every travel_agenecy should have 'Economy' class. I want to find the  name of 'travel_agenecy' from query which has not 'Economy' Class.create table #Travel (travel_agency char(4), travel_class...

View Article

Delete Plural if Singular Word also Listed

Looking for an elegant solution: delete plural word IFF singular is present. Sample table:DECLARE @WordList TABLE (ID INT IDENTITY(1,1) PRIMARY KEY, Word nvarchar(100)); INSERT @WordList (Word) VALUES...

View Article

Something wrong with the SQL code in SQL server 2014

Hey there. I have very simple SQL code in SQL server 2014 management studio. Here it is:DECLARE @a INT, @b INT SET @a=COUNT(Capital) FROM [dbo].[list_of_countries] SET @b=@a-1 SELECT @b as...

View Article


Conditionally choose linked server

Hi, Have a stored procedure that accesses data via a linked server.  Whilst testing we point to a test linked server and then change the procedure to a different one when it goes live.  Not ideal.Was...

View Article

Rebuild Heap (Remove Clustered Index)

We have a number of heaps that have high fragmentation.  We are on MS SQL SERVER 2005.I've been told that the ALTER INDEX is only available for 2008+, therefore we need to add a clustered index and...

View Article

INSULL(Column1,'') Make a new system function like ISNULLEMPTY(Column1)

INSULL(Column1,'')     The above function has been greatly used in TSQL and PLSQL.Make a new system function like ISNULLEMPTY(Column1)

View Article


Find Possible Combinations

We are trying to automate the sequence of our order picking process.  Our order picking is based on "lifts", where the max height of a lift is 18 inches.On our item lines we know the height in inches...

View Article


compare two results from the same table

i have two results from the same table that i would like to compare. below is my query and the results i want to compareSELECT tblItemRoutingBOM.ItemRevID, tblItem.ItemID, tblItem.PartNum,...

View Article

How to convert data from rows into columns

Hi,I have a sql table and the data looks like thisGLYEAR GLMN01 GLMN02 GLMN03 GLMN04 2007 -109712.40 6909.15 4758.72 56.88 2007 -13411.32 19132.9 -5585.07 4362.64Where GLyear reprsents Year and GLMN01...

View Article

Combining columns in WHERE IN clause

I get an error when trying to process this SQL statement.  What is the proper way to concatenate the names of two columns in the WHERE and SELECT clauses?SQL = SELECT * FROM @SearchTbl WHERE Name +...

View Article

Getting datetime of the system

Hello, I am using GETDATE() in my SQL statement but I've got this error  when I run my windows application form:Additional information: Conversion failed when converting date and/or time from character...

View Article


Query Help

Hi,I have one big database I want to check for all numeric data type columns I want to check what is min or max value in table. reason to check this is I want to confirm data type is correct like if...

View Article

Get all Table names

Hi Experts,Looking forward to query to get all table column names,Thanks

View Article


not to get certain rows

Hi,We are using sql server 2012. We have one stored proc with multiple queries in it. One of the query is complicated with lot of join and other conditions, whose data is inserted into tmp table. I got...

View Article

Trend Calculation

Hello Forum Members,I have to calculate a Trend value.I have Promised, Trend, Expected, Actual, Date columns.Trend Logic:Past dates including current month  (promised-actual)Future dates...

View Article


Identifying stale data within a time series table

Hello. I am trying to create a query in order to identify stale price data from a table in sqlserver.I have a table with the following columns. 1) effective date2) product ID3) product Name4)...

View Article

t-sql 2008 r2 use results from a temp table

In 2008 t-sql  I have the sql listed below where I obtain results by calling a stored procedure  [test].[dbo].[sroom]. I am joining the results from calling a stored procedure with an existing table...

View Article

Error 1222 : "Lock request time out period exceeded" occurring intermittently

Hi,We are getting the error " Lock Request time out period exceeded" intermittently while trigger execution.I have gone through the blogs and couln't able to find out the root cause and permanent...

View Article
Browsing all 23857 articles
Browse latest View live


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