I'm getting this error ........Msg 156, Level 15, State 1, Line 87Incorrect syntax near the keyword 'where'.I'm probably missing a comma or something somewhere but, can't find anything. Any thoughts?[code="sql"]declare @StartDate datetime, @EndDate datetimeset @StartDate='2016-12-01'set @EndDate='2016-12-31'select RAM.AccountNumber, RAM.VisitID, HRMRN.PrefixMedicalRecordNumber as UnitNumber, HRM.Name, RAM.AdmitDateTime, PCVAC.Item, PCVAC.DatePerformed, case when PCVAC.ChargeType is null then 'None' else PCVAC.ChargeType end as ChargeType, PCVAC.Interventionsfrom livefdb.dbo.RegAcct_Main RAMinner join livefdb.dbo.HimRec_VisitData HRVD on RAM.SourceID=HRVD.SourceID and RAM.VisitID=HRVD.VisitID and RAM.PatientID=HRVD.PatientID and RAM.RegistrationType_MisRegTypeID=HRVD.VisitType_MisRegTypeID and RAM.RegistrationType_MisRegTypeID='IN' --and RAM.Location_MisLocID='CCU'inner join livefdb.dbo.HimRec_Main HRM on RAM.SourceID=HRM.SourceID and RAM.PatientID=HRM.PatientIDinner join livefdb.dbo.HimRec_MedicalRecordNumbers HRMRN on HRM.SourceID=HRMRN.SourceID and HRM.PatientID=HRMRN.PatientID and HRMRN.MrnPrefixID='M'inner join ( --RT:PCV AC select PADM.SourceID, 'RT:PCV AC' as Item, left(PADM.PcsAssmntDataID,21) as VisitID, convert(date, PADM.DateTimePerformed, 121) as DatePerformed, max(case when QuerySetID=6 and QueryNumberID=1 then QueryValue else NULL end) as ChargeType, count(*) as Interventions from livefdb.dbo.PcsAssmntData_Main PADM inner join livefdb.dbo.PcsAssmntData_Queries PADQ on PADM.SourceID=PADQ.SourceID and PADM.PcsAssmntDataID=PADQ.PcsAssmntDataID and PADM.IdentifierID=PADQ.IdentifierID cross apply (select top 1 * from livefdb.dbo.PcsAcctAct_IntActivity where PADM.SourceID=SourceID and left(PADM.PcsAssmntDataID,21)=VisitID and PADM.IdentifierID=InterventionActivityUrnID order by InterventionActivityRecordDateTime desc) PAAIA where PADM.SourceID='BRO' and PADM.PcsAssmntDataID like '%{A^RESP.PCVAC}' group by PADM.SourceID, PADM.PcsAssmntDataID, convert(date, PADM.DateTimePerformed, 121) union --RT:NPPV/BIPAP select PADM.SourceID, 'RT:NPPV/BIPAP' as Item, left(PADM.PcsAssmntDataID,21) as VisitID, convert(date, PADM.DateTimePerformed, 121) as DatePerformed, max(case when QuerySetID=6 and QueryNumberID=1 then QueryValue else NULL end) as ChargeType, count(*) as Interventions from livefdb.dbo.PcsAssmntData_Main PADM inner join livefdb.dbo.PcsAssmntData_Queries PADQ on PADM.SourceID=PADQ.SourceID and PADM.PcsAssmntDataID=PADQ.PcsAssmntDataID and PADM.IdentifierID=PADQ.IdentifierID cross apply (select top 1 * from livefdb.dbo.PcsAcctAct_IntActivity where PADM.SourceID=SourceID and left(PADM.PcsAssmntDataID,21)=VisitID and PADM.IdentifierID=InterventionActivityUrnID order by InterventionActivityRecordDateTime desc) PAAIA where PADM.SourceID='BRO' and PADM.PcsAssmntDataID like '%{A^RESP.BIPAP}' group by PADM.SourceID, PADM.PcsAssmntDataID, convert(date, PADM.DateTimePerformed, 121) )where RAM.SourceID='BRO' and RAM.AdmitDateTime>=@StartDate and RAM.AdmitDateTime<dateadd(day, 1, @EndDate)order by Name, Item, PCVAC.DatePerformed[/code]
↧
How to use a UNION with inner joins
↧
How to SSAS Cube Lineage in SQL Server?
I'm looking for a way to get the metadata lineage information of a SSAS. I want to trackback the measure of cube to its physical column . (i.e. Datasourceview column)Can anyone help on this?I referred the below sites:https://dataself.com/wiki/Cube_Metadata_MDX_Queryhttp://richardlees.blogspot.in/2010/07/querying-analysis-services-for-cube.htmlhttp://www.ssas-info.com/analysis-services-articles/66-mgmt/2701-ssas--using-dmv-queries-to-get-cube-metadataAll are giving the details of cube objects , but not the relationship between Datasource view and Cube .
↧
↧
Unique Indexes With Multiple Keys
All,Two part question:1) Given a table with N columns (N1, N2, N3, N4, ... etc) and assume that column N1 is a clustered PK and column N2 has a unique index/constraint defined on it. Let's further assume for simplicity that these are all INT columns. Is it the case that any index defined that includes column N2 (the column defined as unique) can also be defined as unique? For example, an index that has key columns defined as N2, N3, N4 or as N4, N2, N3 could be defined as unique even if columns N3 & N4 aren't necessarily unique. I'm pretty sure the answer is yes, but want to make sure. :)2) Given the answer to #1 is yes, would it be beneficial to define any index that has column N2 as a key column to be defined unique? Will it help the optimizer generate more efficient query plans having the unique index vs non-unique?Thanks!Peter
↧
SQl Agent Mapped drive dilemma
Just trying to referenced a mapped drive in SQl Agent. The service acct for SQl Agent is a domain acct with local admin rights on the 2008 r2 server.I need to access a shared folder on a different 2008 r2 server. I thought Net use would do it but whenever I list the shared folder, it errors out. I've confirmed my sql agent service domain account has access to the share. net use J: \\servername works net use J: \\servicename\shared drive does not. Do I need to use xp_cmdshell to do this?
↧
How to Add Line feed in query result
HelloI have a query where I have to append line feed in one column result among 8 columns like below[u]Month Name[/u] [u]Amount[/u] [u]PaymentMode[/u]January - 10 10000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123456January - 10 70000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-908765January - 10 30000 Credit Card [here line feed]xxxx-xxxx-xxxx-9897 [here line feed]Tran Detail-123432How can I achieve this, any idea would be appreciated..Regards,
↧
↧
erdg esrfsdf erfeszdfz
[url=https://www.youtube.com/watch?v=c0HSsb_SiZY]Chiefs vs Broncos Live Stream[/url][url=https://www.youtube.com/watch?v=K2JaWfpTlVE]Chiefs vs Broncos Live Stream[/url][url=https://brandguide.asu.edu/sites/default/files/webform/chiefs-vs-broncos-live-stream-dec-25.pdf]Chiefs vs Broncos Live Stream[/url][url=https://brandguide.asu.edu/sites/default/files/webform/chiefs-game-arrowhead-field-preview-must-watch-game-online-hd-full-pod-cast-show.pdf]Chiefs vs Broncos Live Stream[/url][url=https://brandguide.asu.edu/sites/default/files/webform/cbs_tv_chiefs_vs_broncos_live_stream.pdf]Chiefs vs Broncos Live Stream[/url][url=https://brandguide.asu.edu/sites/default/files/webform/usa_football_broncos_vs_chiefs_live.pdf]Broncos vs Chiefs Live Stream[/url][url=https://brandguide.asu.edu/sites/default/files/webform/cbs-tv-broncos-vs-chiefs-live-streaming-snf-online-hd-tv-guide.pdf]Broncos vs Chiefs Live Stream[/url]
↧
SSIS - Export multiple SQL queries to one excel spreadsheet
Hi All,I am using SSIS and I am trying to export 3 separate SQL queries to one excel spreadsheet. These queries each have different number of fields and different metadata. I need to export them to the excel sheet and have 3 sections with the resultsets from the queries.Anyone know how to do this using SSIS? Any help appreciated!
↧
Missing the CTP1 from SQL Server 2008 r2
Using sql server 2008 r2 Dev. edition and it loaded the 2008 VS shell. Everything is working finebut I am missing the Source and Destination Assistants, upgrade toolbox. These objects and others are in theCTP1. Without installing another sql server instance, is there a way to install/import the CTP1upgrade. Thanks,RTP
↧
Database Mail Not Sending Outside the Company
DBMail has been sending out email with attachments inside and outside the company. Added new recipients to existing report which other people are receiving inside and outside the company. New email is outside the company but keep getting the error message:"The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2016-12-27T04:48:08). Exception Message: Cannot send mails to mail server. (A recipient must be specified.). "Able to send test E-Mail and user gets the email. Also, able to send email with attachments to users through Outlook 2110. Because of error above I would think the problem on our side, but cannot find the problem. These reports have been going out with attachments to everyone.Thanks for any help
↧
↧
Missing user defined variable in the Script Task Editor
Using SSIS 2008, having problem in the Script Task Editor, under ReadOnlyVariable, hit the ellipse button butmy user defined variable is not showing up, only system variables.On the Data Flow Tab, Excel Source connected to the RowCount. Double click on RowCount and the Editor forRow Count appears and at bottom for Variable Name, hit the ellipse button and I find the user defined variable I created.On the Control Flow Tab(I did this first), Data Flow Task. I tested what I have to this point and everythingworked out because the Row Count return 100 rows.Then I drop a Script Task on the Control Flow, connected the Data Flow Task to the Script Task. Double clickon the Script task, and the editor window appeared. When I hit the ellipse button on the ReadOnlyVariable, Ionly see the System variables and NOT my user defined variable. I was able to see it under the Data FlowTab, but not on the Control Flow tab.I do not know what I am missing.Thanks.
↧
led to widespread protests and a decision
[url=https://www.tchs.org/sites/default/files/webform/Temple-vs-Wake-Forest-Live-Stream-College-Football-NCAAF-27-Dec-2016-Game.pdf]Temple vs Wake Forest Live Streaming[/url]
↧
Analyze Table structure for best data type
Hi,I have a table that was imported from Oracle and all numeric data type were transferred as numeric (38,0). I am looking for a tool\script to analyze the data in each column of a table and recommend an appropriated datatype. For example, a column has a min value of 0 and a max value 1,000,000. Recommendation would be to use an INT datatype.Thanks
↧
User defined variable value is not being updated in the Script Task
Using SSIS 2008, I was able to make my variable global. My Script task has a Message.Show with the variable. Example, The number of rows are (then the variable results). However, my variable here is zero and it should read 101. When I execute my package, in the Data flow tab, I see the "101 rows" between Excel Source andthe Row Count. But the 101 is not making it to the Script task, Simple code:MessageBox.Show("There are " + Dts.Variables["NumberRows"].Value + " rows");NumberRows is my variable.Also, I am getting the following warning for each of my column headings from Excel workbook and how do I correct it:[SSIS.Pipeline] Warning: The output column "Id" (41) on output "Excel Source Output" (9) and component "Excel Source" (1) is not subsequently used in the Data Flow task. Removing this unused output column can increase Data Flow task performance.On the Data Flow Tab, Excel Source connected to the RowCount. Double click on RowCount and the Editor forRow Count appears and at bottom for Variable Name, hit the ellipse button and I find the user defined variable I created, NumberRowsOn the Control Flow Tab(I did this first), Data Flow Task. I tested what I have to this point and everythingworked out because the Row Count returned 101 rows.Thanks,rtp
↧
↧
Error - Logical file is not part of database. Use RESTORE FILELISTONLY to list the logical file names
I made a script to restore .bak or backup files. It works for some databases, but not for one. How do I make it work for any type of .bak file ? This is in sql server 2008. The error message is -Msg 3234, Level 16, State 1, Line 1Logical file 'Northwind_Data' is not part of database 'Northwind'. Use RESTORE FILELISTONLY to list the logical file names.Msg 3013, Level 16, State 1, Line 1RESTORE DATABASE is terminating abnormally.Script -IF DB_ID('Northwind') IS NULLBEGINRESTORE DATABASE [Northwind]FILE = N'Northwind_Data'FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SS2008\MSSQL\Backup\Northwind.bak'WITH FILE = 1,MOVE N'Northwind_Data'TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SS2008\MSSQL\DATA\Northwind.mdf',MOVE N'Northwind_Log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SS2008\MSSQL\DATA\Northwind_0.LDF',NOUNLOAD, STATS = 10END
↧
Replication - Log file Size & Usage high
Hi,I have a transactional replication built in 2008 environment. My Log file size keeps growing and its usage is always 99% and i am not able to shrink the log also. Please help. Thanks in advance!Chelladurai
↧
ERROR - HELP PLEASE: A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: -1, output error: 0).
We are seeing the following error on a few of our systems ... I've searched the internet, but cannot find the "exact" error. Any suggestions?A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: -1, output error: 0).
↧
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.
↧
↧
SQL Server 2008R2 SP3 install terminates after extract
I successfully applied 2008R2 SP3 to the Analysis Services and shared services. After the install, I rebooted the computer. Now, I am trying to apply SP3 to the database instance. I run the installer as administrator, it opens and extracts files, flashes a black window and then closes. No error message. I am new to SQL Server and, so far, I have not found any log file that will give me a clue as to the problem. I have tried rebooting the server, multiple times, and I continue to have the problem. Any suggestions? Thanks,Nancy
↧
Data alignment
Hi all,I have two tables that I'm trying to reconcile the dollar amounts. However, I'm encountering some issues when the data does not align perfectly based on the fields that I'm using to join the tables.The disparity is due to when the datebegin date does not align to the attributing "month" field, and when I join on the month field there is data loss. insight is needed on how I can alter my code to align the data to make sure I capture the total amount accurately from both tables.My expected query result is to have $38,786.82 from table A and $38,786.82 from table B.I'm getting $8,858.43 for table B.Your insight is greatly appreciated, thanks.[code="plain"]--Problematic aligment in tableTable A Month Serial Number Datebegin Dateend PaidMar-15 0000000000001 3/16/2015 0:00 4/10/2015 0:00 $38,786.82 Apr-15 0000000000001 4/7/2015 0:00 4/13/2015 0:00 #N/AApr-15 0000000000001 4/10/2015 0:00 4/30/2015 0:00 $35,600.00 Table B Month Serial Number Datebegin Dateend PaidMar-15 0000000000001 4/7/2015 0:00 4/10/2015 0:00 $8,838.13 Mar-15 0000000000001 4/7/2015 0:00 4/10/2015 0:00 $20.30 Apr-15 0000000000001 4/7/2015 0:00 4/10/2015 0:00 $29,928.39 Apr-15 0000000000001 4/10/2015 0:00 4/30/2015 0:00 $35,600.00 --Perfect alignment in table:Table A Month Serial Number Datebegin Dateend PaidMar-15 0000000000001 3/20/2015 0:00 3/23/2015 0:00 $10,721.14 Table B Month Serial Number Datebegin Dateend PaidMar-15 0000000000001 3/20/2015 0:00 3/23/2015 0:00 $10,721.14 query:select A1.Month, sum(A1.Paid)PaidAmount, B1.Month, sum(B1.Paid)PaidAmount from Table A as A1 left outer join TableB as B1 on A1.Serial Number = B1.Serial Number and A1.Month = B1. MonthGroup by A1.Month, B1.Month[/code]
↧
Find who is changing advaced options in SQL 2008
we are keep getting following alert in SQLConfiguration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install.I have enable the trace to see the but no luck,In my trace , I have enabled TextData,BatchStatrted,Batchended and couple of other columns as well.Appreciate your help
↧