The data represents the results of an echocardiogram. I need to get the numerical results out of this string. So, find the "%", then get the numbers in front. Problem is, there could be a value of <25%, or >65%. Any thoughts?[code="sql"]create table #T(TextID varchar(30),TextLine varchar(300))insert into #T(TextID, TextLine) values('14898341','The visually estimated ejection fraction is between 60-65%. There is')insert into #T(TextID, TextLine) values('14898395',' The visually estimated ejection fraction is between 60-65%. ')insert into #T(TextID, TextLine) values('14899043','The visually estimated ejection fraction is between 60-65%.')insert into #T(TextID, TextLine) values('14899103',' The visually estimated ejection fraction is between 60-65%.')insert into #T(TextID, TextLine) values('14899809','The visually estimated ejection fraction is between 60-65%.')insert into #T(TextID, TextLine) values('14899867',' The visually estimated ejection fraction is between 60-65%.')insert into #T(TextID, TextLine) values('14901939',' The visually estimated ejection fraction is between 60-65%. ')insert into #T(TextID, TextLine) values('14902098','The visually estimated ejection fraction is between 60-65%.')insert into #T(TextID, TextLine) values('14902160',' The visually estimated ejection fraction is between 60-65%.')insert into #T(TextID, TextLine) values('15588094','nd wall motion. The visually estimated ejection fraction is between 60-65%. Right Ventricle Normal right ventricular cavity size, wall thickness, and systolic function. Atria Both atria are normal i')insert into #T(TextID, TextLine) values('15475551','The left ventricular ejection fraction was calculated to be 71%. (Normal >50%).')insert into #T(TextID, TextLine) values('15478850','t presents with acute on chronic diastolic congestive heart failure with ejection fraction around 60%. Seen by cardiologist and the current cardiothoracic team. Being contemplated for placement of an ')insert into #T(TextID, TextLine) values('15486629','The left ventricular ejection fraction increases with stress. The ejection')insert into #T(TextID, TextLine) values('15487054','Normal left ventricular systolic function with an ejection fraction of 55-60%')[/code]
↧
How to parse numbers out of text string
↧
Finding the top row of a range
Given the following table and data:[code="sql"]declare @t table( FeeTable int, OffSet int, Amount decimal(13,2));insert @t (FeeTable, OffSet, Amount) values (10, 4, 20.00), (10, 3, 65.00), (10, 2, 90.00), (10, 1, 135.00), (10, 0, 175.00), (11, 4, 10.00), (11, 3, 25.00), (11, 2, 30.00), (11, 1, 435.00), (11, 0, 575.00);[/code]It is trivial to return the correct row when the offset that is passed in is between 0 and 4 for a given FeeTable. I am having a hard time trying to return the largest offset in the range when the passed in offset is > 4. Thanks!
↧
↧
continued entertainment with xp_cmdshell
Previously, I changed the service acct to domain on a SQl 2008 R2 machine and received an SPN error.The machine could not be accessed remotely, so I changed the service acct to NT AUTHORITYetwork service. This restored remote connectivity but I have another issue.This machine has a TSQL Job that uses ROBOCOPY to copy backup files to a second server. NT AUTHORITY does not have adequate permissions so I created a proxy acct for XP_CMDSHELL. I gave this account read/write permissions for the folders I am using on both servers. I ran the TSQL Job and received an error saying [b]Access Denied[/b]. Is the problem the NT AUTHORITY service acct or do I need to get Domain Admin permissions to fix the SPN problem? Thank you.
↧
Data migration approach
Hello friends, I am just started working in SQL Server. Currently I have a requirement where data has to be migrated from a CSV file to SQL table. It's simple for one time. However I have to load the table as and when new file comes with truncate and load. There is no scheduled frequency and data has to be loaded as and when needed. One more thing, I have to have the control of the process in production environment. If it's a job then we have to go to DBAs to run the job Everytime we need data load.So what do you think should be good approach to implement it ?
↧
Restoration takes too long
Hi all.In my office we are using MS sql server 2008r2. We have a backup files but one of the files takes too long to be restored. Approximately it should not take more than 5 minutes and sometimes took 1hr which is very headache.I need to know what is the exactly problem and how to fix it. The size of backup file is 3gb.Your help guyzNote:Am junior DBA
↧
↧
How to update column value
I have a sql code like below in my stored procedure:INSERT INTO PRIOR_DIST (_ID, [b]COSTS_DST[/b], IS_ACTIVE) SELECT @_id, [b]COSTS_DST[/b], 'Y' FROM PRIOR_DIST WHERE _ID = @id_prev;currently It fetches previous record and insert as new record. I'd like to modify the insert code . I want to update COSTS_DST received from select query by multiplying with a constant value and and then insert.@const1=4.000@const2=6.000COSTS_DST = (COSTS_DST*@const1)/@const2 // upto ten decimalI'd like to insert this updated value .I'm not sure what changes I need to do in my code.
↧
timeout issue
I am on 2008R2, trying to update an existing table (70M rows) with a new ID as primary key. I do have the timeout setting as 0 which presumably means no time-out.I got time out error message within 1 minute.What am I missing here?What's the best way to add primary key to [color="#ff0000"]existing [/color]large size table?Thank you very much.
↧
Select * return 24 while select count(1) return 3956892
This is really an interesting finding, please refer to my screenshots.What am I missing here? I cannot understand this finding.
↧
Fragmentation details greater than 25% - powershell script
Need Powershell script to find the Fragmentation details greater than 25% for a list of servers and the results needs to be exported in excel. Please help.
↧
↧
two backups - false alert
Hi,We have SQL job scheduled to run in the midnight. Due to the space issue it failed 2 days. After that we added more space but we noticed that we are getting backups two times for each database. It is taking each database backup twice.There are no change in the backup job but why it is running two times.
↧
script to find if SSRS / SSIS service is installed
Was wondering if anyone had/knew of a script that would check to see if SSRS/SSIS is installed on an instance. We have hundreds of SQL instances and trying to find an easier way of checking for this as opposed to doing this manually.
↧
syntax error
There is syntax error in the code.[i]Incorrect syntax near 'id='.[/i]INSERT INTO LOG_RATE_MONTH(LOG_MESSAGE,LOG_DATE)('id='+@_prev,getDate());@_prev is a sql variablewhats the issue in this code ?
↧
Sportsmanship is an attitude that strives
[url=https://barretthonors.asu.edu/sites/default/files/webform/giants-vs-packers-live-stream-nfl-wild-card-playoffs-match-08-jan-2017-online.pdf]Giants vs Packers Live Streaming[/url]
↧
↧
Reindex DB on regular basis
Hi all!I have a database where app. 10.000 records are deleted/updated/inserted pr. day.I have understood from other sources, that i should reindex the db on a regular basis.Locally, where i backup/restores it up to many times pr. day, the speed has went down to a crawl.Where do i find some 'Hands on' info on 'How to', and pro et cons?The database is today a 2008R2, but wil get updated to 2012 or 2016 sooner or laterDB size: 26807,88 MBBest regardsEdvard Korsbæk
↧
Is SQL Server 2008 and 2008 R2 completely separate versions?
Hello,Is SQL Server 2008 and 2008 R2 completely separate versions?I currently have the "out of the box" SQL Server 2008 installed on my machine but need to utilize functionality that is part of BIDS that comes in 2008 R2. However, when I attempt to install, the only option I get is for SQL Express and while the R2 installs "successfully", my SQL Server and BIDS does not take effect.I am curious to know if they are 2 separate products???
↧
I'm Having Trouble Parsing This Date Calculation Expression
I inherited a bunch of code from a predecessor at my job, and I'm trying to go through it all to make sure I understand what it's doing. There's this one line in particular that returns the first day of the current month. It works fine, but it's not clear to me [i]how[/i] it's getting there. The code looks like this:[b]Select DATEADD(month, DATEDIFF(MONTH, 0, getdate()), 0);[/b]When I run just the [b]DATEDIFF(MONTH, 0, getdate())[/b] part of the code, I get 1404, which I completely don't understand the meaning of. I've tried to look up what happens when you use a 0 in the second parameter when SQL is expecting a date value, but I cannot find anything.When I run [b]DATEADD(month, 1404, 0)[/b], I get '[b]2017-01-01 00:00:00.000[/b]', which is the value that I want; but how SQL processes these integers in a date datatype environment is not clear to me.Can somebody break this down for me?Thank you!
↧
parameter Length problem while running query
Hi Genius , while i am running this code query should be truncated. please some one help me how to increase stored size-- Table creation : create table ##temp_2_5(option_oemcode varchar(50),category_name_natlang varchar(3000),option_name_natlang varchar(3000),transmission_natlang varchar(1000),body_natlang varchar(500),powerunit_natlang varchar(1000),modeltrim_name varchar(255),is_non_specific_option bit,upholstrey bit,Is_standard_equipment bit,rule_natlang varchar(3000),rule_type varchar(1000))-- insert values :insert into ##temp_2_5 values('','','Active City Stop','','','','Black',0,0,0,'',''),('','','Active City Stop','','','','Business Nav',0,0,0,'',''),('','','Active City Stop','','','','Business Nav ECOnetic',0,0,0,'',''),('','','Active City Stop','','','','Red',0,0,0,'',''),('','','Active City Stop','','','','RS',0,0,0,'',''),('','','Active City Stop','','','','ST',0,0,0,'',''),('','','Active City Stop','','','','ST-Line',0,0,0,'',''),('','','Active City Stop','','','','Titanium',0,0,0,'',''),('','','Active City Stop','','','','Titanium ECOnetic',0,0,0,'',''),('','','Active City Stop','','','','Trend',0,0,0,'',''),('','','Active City Stop','','','','Trend ECOnetic',0,0,0,'','')select * from ##temp_2_5-- code : DECLARE @SQL2_5 NVARCHAR(MAX) ,@DynamicList2_5 NVARCHAR(MAX) = '' ; --===== Create the dynamic columns for the SELECT list SELECT @DynamicList2_5 += REPLACE(REPLACE( N',[<<[modeltrim_name]>>] = MAX(CASE WHEN [modeltrim_name] = "<<[modeltrim_name]>>" and [option_cost_inclusive_tax] is not null THEN cast(a.option_cost_inclusive_tax as varchar(50)) WHEN [modeltrim_name] = "<<[modeltrim_name]>>" and [option_cost_inclusive_tax] is null THEN "Blank_Found" ELSE "" END) ' ,N'"',N'''') ,N'<<[modeltrim_name]>>',[modeltrim_name]) FROM ##temp_2_5 GROUP BY [modeltrim_name] ORDER BY [modeltrim_name] ; --===== Wrap the dynamic part of the SELECT list in the rest of the code. SELECT @SQL2_5 = REPLACE(N' select option_oemcode ,category_name_natlang ,option_name_natlang ,transmission_natlang ,body_natlang ,powerunit_natlang <<@DynamicList2_5>> ,case when is_non_specific_option = 1 then ''True'' else ''False'' end as is_non_specific_option ,case when upholstrey = 1 then ''True'' else ''False'' end as upholstrey ,Is_standard_equipment ,rule_natlang ,rule_type FROM ##temp_2_5 a GROUP by option_oemcode ,category_name_natlang ,option_name_natlang ,transmission_natlang ,body_natlang ,case when is_non_specific_option = 1 then ''True'' else ''False'' end ,case when upholstrey = 1 then ''True'' else ''False'' end ,powerunit_natlang ,Is_standard_equipment ,rule_natlang ,rule_type ;' ,N'<<@DynamicList2_5>>',@DynamicList2_5) ; --===== execute the Dynamic SQL print @SQL2_5; -- exec @SQL2_5
↧
↧
CPU usage for previous month
Hi I'm trying to find the cpu usage for the month of Dec2016. Can anyone let me know the steps/t-sql to achieve thisregards
↧
Initial size for TempDb data and Log file?
Hi,We have installed SQL Server 2008 R2 SP1 instance and it's having Share Point 2010 databases.We have 2 dedicated drives for Tempdb on SAN with 50 GB space. Both tempdb data & log files are created with default size. I would like to presize them. What are the best values to start with?U ->Tempdbdata having tempdb.mdf fileV->Tempdblog having templog.ldf fileThanks
↧
How to plot disk utilization for entire month
HiI have three drive (C,D,E). I need to plot a graph for the disk utilization for Dec2016 for these drives. Is there any script to capture the data so that the graph can be createdThanks
↧