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

Rectifying Divide By 0 query

The following is part of my SELECT clause that is giving me divide by 0 error:[TotalHours]/SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) AS 'MTBF'Im trying to rectify the divide by 0 like...

View Article


Getting Error while enabling CDC on the database

Hi Experts,I am trying to enable CDC on my database but i am getting error message like below, can anyone please suggest on this .The server principal "XXXX." is not able to access the database "ABC"...

View Article


sp_configure

hi,step 1sp_configure 'show advanced options', 1 ; GO RECONFIGURE ; GO sp_configure 'blocked process threshold', 1 ; GO RECONFIGURE ; GO step 2sp_configure 'show advanced options', 0 ; GO RECONFIGURE ;...

View Article

Julian Date to Date(time) Conversion

What is the best way to convert Julian date to date (or datetime)?  Thanks.-- Julian to date conversionDECLARE @JulianDate char(7) = '2011099'SELECTCONVERT(DATE,DATEADD(day, CAST(RIGHT(@JulianDate,3)...

View Article

Counting rows on table with TEXTIMAGE_ON

For many-columned fixed length files I created and loaded this table:CREATE TABLE [dbo].[Fixed_Length_Text_Files]( [Line] [text] NULL, [Text_File_Id] [bigint] NULL, [ID] [int] IDENTITY(1,1) NOT NULL,...

View Article


rowlock and updlock difference

rowlock and updlock difference and when there use

View Article

has mssql2008r2 got "Cumulative Update Package 6 for SQL Server 2008 Service...

hi,I haveMicrosoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (Intel X86)   Apr  2 2010 15:53:02   Copyright (c) Microsoft Corporation  Express Edition with Advanced Services on Windows NT 5.1 <X86>...

View Article

Linked server permissions error

Hi,I have created a linked server. Test connection is successful (Right click--> Test connection)There a table in the remote server and i can see the rows of the table using SELECT query.Now i...

View Article


How to return multiple rows in case when condition?

I want to display the list of product names owned by a company.If no products found it should return a string like "NO PRODUCTS FOUND'The query I wrote working well but when the condition does not...

View Article


Split the column into two based on conditions

Hello,I have 2 tables Country and Continent.Continent has the data like thisID               Name1               Asia2              Africa3              North America4             South AmericaCountry...

View Article

get max date within a quarter

Hi,i have the following dates:1-1-20142-1-20143-1-20144-1-20144-22-20146-1-2014I need to get the max date(s) from the list for each quarter, so I will need to end up with this:Quarter  MaxDateQ12014...

View Article

Insert into two linked tables via query designer in visual studio?

I have two tables name Roster And RosterTimes which are linked via the column DateId. I need to insert into the column name in table Roster and Date and Area columns in the table RosterTimes. How would...

View Article

Convert columns into rows in a dataset

Hello,I am working on a query whihc actually shows the count of countries for each continent. This is my queryCreatetable continent (ID INT, Name VARCHAR(30))INSERT continents...

View Article


DELETING multiple rows

I am trying to delete rows from two tables the relevant information is the same as in this...

View Article

Image may be NSFW.
Clik here to view.

Access a array variable in sql script?...

Hi,I have a SQLite database I will be using eventually for my app, also will use Azure as my server.  Right now on my system using SQL Express and Azure Emulator for testing.  I've already created the...

View Article


Split the result of one column to multiple columns

Hi Experts,Could you please help me to split the result of below query into multiple columns:EXEC master..xp_cmdshell 'wmic service where "Caption Like ''%sql%''" get Caption , StartName, state'I needs...

View Article

The mechanics of the WHERE clause

I’ve been out in industry for over 10 years now doing DB work most of that time. Lately I’ve been doing some work that is starting to challenge my long held assumptions about the internal workings of...

View Article


Dynamic SQL Question

CREATE TABLE [Reference].[CRKAttr]( [CRKID] [int] IDENTITY(1,1) NOT NULL, [Client] [varchar](100) NULL, [AttrOrder] [int] NULL, [AttrTable] [varchar](100) NULL, [Attr] [varchar](100) NULL ) ON...

View Article

Populate a column based on if it's null or not..!

Hello Gurus, I'm trying to populate a column based on if it's null or not. If it's null i want to populate with another column values. If it's not null then populate with the same column value. I wrote...

View Article

Insert with Output clause

INSERT INTO OrdersOrderName, OrderDateOUTPUT INSERTED.OrderIdSELECT OrderName, OrderDateFROM @tvp (table valued parameter)I want to include other columns from the tvp that are not inserted into the...

View Article
Browsing all 12890 articles
Browse latest View live


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