CTW with Outer apply and using a parameter
I am using the query below to select all the repair jobs and then select the First invoice service date that happened after the repair. I do not understand when i run the query wide open it does not...
View Articleget 10 digit number from string
Hi allI have one string I need to get 10 digit number from it .1.abnh-US-HoP--String-123770752-21-Mar-132.sdfn-fdsfnter-1234567890I require only 1.1237707522.1234567890Please help.
View ArticleQuery needed
Can somebody help me with a query. I want to get all the IDs which has 'somecode' and 'M' code. Here IDs 101 and 103 would get selected. declare @temp table (ID int, code int) insert into @temp...
View ArticleHow to Determine if Anyone is Using a Database?
I am not sure where to ask this question.I have just started working at a new company. I am migrating their SQL Server 2000 databases to SQL Server 2012. I have two databases where no one is not sure...
View ArticleNumber of days patient was on ventilator
Here is the sample data. The problem with the data is the patient is put on ventilator from time to time if you see for the patient_id 3 with a visit id of 300 he was put on ventilator multiple times...
View ArticleCalculate sum based on another column
how to calculate sum of a column values based on another column value without creating view or function in a sql server.EX: Col 1 Col 2 Col 3 = Col2/Sum of same value from col1 A 1...
View ArticleJoing two databases and then Outer Joining
Hi ,I;m fairly new at SQL 2012 so hopefully someone can help me.I've been asked to do the following on some tables and could use some input.I want join fron database A table1 and table2.I would assume...
View ArticleSQL to calculate time difference between two different rows and columns
i have to calulate the total length of time driver travelled in each location each time.i am using sql server 2008 version the DDL for this table is DECLARE @TEMP TABLE (VEH_NO VARCHAR(10),DRIV_NO...
View ArticleTop 2 rows
Hello,I want to pull only the last 2 dates (TB.FLDDATE) from the TUBER table. Do you have any insight on how to do this on the below...
View ArticleNeed help to speed up a qurey.
I have two tables (table1 and table2) which both have similar data. Both table1 and table2 have over 100000 records each in them. I need to concatenate three columns that are in table1 and compare...
View ArticleNeed help with a query for an interesting situation
Hello,I have a column named name and it has the names in the below format with first and last name together Sachin TendulkarSourav,GangulyMahender S DhoniSuresh, RainaRahul ,Dravidand i want to select...
View ArticleGet Two Highest Records for specific IDs and convert both to columns
Hi, Here are my sample tables.SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[tblAudit_tblEmployee]( [AuditID] [int] IDENTITY(1,1) NOT NULL, [EmployeeID]...
View Articlet-SQL stored proceedure security
Hi,What would be a bad implementation of security when it comes to Stored Procedure code?Is it possible for someone to send a malicious string into a parameter and have malicious code...
View Articlevery slow query. need help to make it faster. thanks
<object height="1" id="plugin0" style=";z-index:1000;" type="application/x-dgnria" width="1"><param name="tabId" value="{E1A896E1-C1AB-45B7-AC2A-CE56BA2BDBC3}" /></object>I have a...
View ArticleSQL Query for Selecting informaitno in a Group
I would like to get information for each group of order_number, there will be only maximum two records (A & B) for each group (e.g. AB002231)There may be cases fora) both A & B records contains...
View ArticleHow to drop all columns in all databases starting with... AND how to drop the...
I am trying to drop some columns from all tables in a database. I can generate multiple scripts on all databases (see below) but how can I now execute them automatically without copying and pasting...
View ArticleInsert from tabbed file with a conditional and table lookup
I need help with a stored procedure.I have two tablesCRIS_USER and CRIS_USER_ LOCATION. CREATETABLE[dbo].[CRIS_USER]...
View ArticleHow to get the day number from Getdate ()
How to get the day number (001 - 365) from Getdate () in 3 digit format?
View Articleinsert documents into sql server 2008 r2 from asp.net
hi all, i am having a rerquirement to store documents in my sql server. And later i wanna retrieve and render it as a link in my asp.net webform.so i would like to know how to insert the documents...
View ArticleHelp with pivot on course data
Hi, I sincerely hope somebody can help me with this? :-)This is my first post here so please excuse any mistakes or ambiguities.I have a query as follows:SELECT...
View Article