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

Users say "database is slow," SQL trace shows otherwise, could SQL Server...

Hi All,Just moved into a new job and got my first task: figure out if it's SQL Server that's causing users to wait a typical 45-60 seconds for GUI queries to return simple search results.  The DB is...

View Article


LOOP in SQL for extracting string from one table and counting that string in...

 I have this query select COUNT(*) from Table 1 where Keywords like '%acetone%' I want to use the loop for taking input from table 2  instead of giving input word by word '%acetone%', and can do it for...

View Article


PIVOT with Ranges /Pivot con rangos

Hola Estoy creando una instrucción SQL con Pivot para encontrar los totales de una tabla cuyo mes este entre 1 y 3 mes, 3 y 6 meses y mayores a 6 Al hacer el SQL no logro relacionar IN ya que no se...

View Article

Counts Per Hour

I have the query below and the results below that.  Would someone tell me how I would be able to run this for multiple days?  If I change the date in the query it will just add to the specific time...

View Article

Pivoting Query Assistance

Hi Experts,Could you please help me in a pivot query? My table structure is given below:CREATE TABLE [dbo].[SS_TestTable1]( [ID] [int] NOT NULL, [Name] [nvarchar](100) NULL, [EmailID1] [nvarchar](50)...

View Article


Problem finding missin data between two tables

 I have two nearly identical tables: labprofiles, labprofiles1.  They have the same columns except labprofiles1 has a profileid columnThe schema looks like this:CREATE TABLE [Edidata].[labprofiles](...

View Article

Left Join with 3 Tables

This is a SQL question mostly so don't be put off by the SCCM references please.I'm trying to query SCCM to get a list of ALL machines and the updates that apply to them. If there are no updates, just...

View Article

Nested CASE expressions

Hi, For some reason when I use the below CASE expression in my SELECT statement I get duplicate records. Also tried using coalesce with no luck. How to write a nested CASE expression which would yeild...

View Article


Nested CASE expressions in SQL Server 2008 R2

Hi, For some reason when I use the below CASE expression in my SELECT statement I get duplicate records.CASE WHEN <Condition 1> THEN <Expression 1> WHEN <Condition 2> THEN...

View Article


T-SQL Calander Question

I need to create a table that will have 3 fields Week Number -- Begin Date --- End Date.  The begin day is Monday, end day is Sunday.  There has to be some built in SQL function or a quick way to do...

View Article

Image may be NSFW.
Clik here to view.

Filling missing dates

Hi. I have the following scripts and I am showing the results in images.CREATE TABLE [dbo].[DetalleLibroBancos]( [IdDetalleLibroBanco] [int] IDENTITY(1,1) NOT NULL, [IdOpBancaria] [int] NULL,...

View Article

Image may be NSFW.
Clik here to view.

Problems reading a bigint from a table

We have a table that has a bigint identity column. WE have a sproc that returns the max value of the identity column as a bigint. IT returns it in a resultset.We have a utility that runs on Unix, which...

View Article

updating unique key column

I have a integer column "ColumnX" and has a unique key on it. The records stored in the table are as follows,CoulmnX            CatID--------------------------------101                       1102...

View Article


Fragmentation = EVIL

On a regular basis, the question is asked when a table should be defragmented.Often, several different people respond with quite different answers. There is a good rule of thumb (if at least 100 pages...

View Article

Seperated by a Semicolon in SQL

Hi,         I have a column(Service) in SQl table that is seperated by Semicolons ,one more column(Code) and is seperated by semicolons.I need to match both the columns data ending by semicolon .SQl...

View Article


One to many query question

I have the following table structureSubjectSubjectID intSubjectDetails (varchar(100)SubjectTypeSubjectTypeId (PK)SubjectID (FK)SubjectType (varchar(30)I want to have this type of result set which is...

View Article

How to split comma delimited string?

Hi, I have a parameter called Id in my SP which will be of nvarchar data type and i'm going to get the multiple ids at a time seperated by commas in that parameter from the application. Now my...

View Article


Query to Summarize

Hi All,I have a table with detailed records in a table.For example,col1 col2 col3 col4 benefit  1236  30  Peter Samuel 40.00 1236  30  Peter Samuel 50.00I want to summarize the single value col1 whose...

View Article

convert varchar(4) to time

Dear.in database I have char(4) which I need to change into timefor example: in my column i have record like 0900 or 2300...how can I convert that values into time 09:00:00 or 23:00:00 thanks for...

View Article

How to convert a "char(4)" datatype to "time" datatype

I have a "char(4)" column whose values I need to change to a "time" datatype in 12 hour format.  For example, I have "1600" and I need to change that to "4:00pm".  I don't need to update the values in...

View Article
Browsing all 23857 articles
Browse latest View live