| Author |
Topic |
|
jayram11
Yak Posting Veteran
97 Posts |
Posted - 2010-06-24 : 17:28:58
|
| Hello I use this query to updatemerge hospital using ( select PRVDR_NUM, ORG_NPI_NUM FROM overlap ) AS OVR (PR, NPI)on (hospital.Ho_num = OVR.PR)when matched then update set hospital.HO_NPI = OVR.NPI;but it gives me a errorMsg 170, Level 15, State 1, Line 2Line 2: Incorrect syntax near 'merge'.Msg 156, Level 15, State 1, Line 8Incorrect syntax near the keyword 'AS'.table hospital: ho_num (PK) char, ho_npi are charoverlap: PRVDR_NUM,ORG_NPI_NUM are varcharany reason why i get this error? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-24 : 18:58:31
|
1) Previous statment must be terminated by a semicolon2) Compatibilitty level must be set to 100 or more N 56°04'39.26"E 12°55'05.63" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-24 : 19:00:31
|
[code];MERGE dbo.Hospital AS tgtUSING ( SELECT PRVDR_NUM, ORG_NPI_NUM FROM dbo.Overlap ) AS src(PR, NPI) ON src.PR = tgt.Ho_numWHEN MATCHED THEN UPDATE SET tgt.HO_NPI = src.NPI;[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
|
jayram11
Yak Posting Veteran
97 Posts |
Posted - 2010-06-25 : 09:40:22
|
| helloi used this to change my compatibility levelALTER DATABASE BRSDATASET compatibility_level = 100;gothe current compatibility level is 80i am working on SSMS 2008and when i run the Alter command above i get Msg 170, Level 15, State 1, Line 3Line 3: Incorrect syntax near '='.any helpthanks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-25 : 11:48:51
|
Well, even if you work with SSMS 2008, your database may still be SQL Server 2000.What does SELECT @@VERSION return for you? N 56°04'39.26"E 12°55'05.63" |
 |
|
|
jayram11
Yak Posting Veteran
97 Posts |
Posted - 2010-06-25 : 13:55:42
|
| Microsoft SQL Server 2000 - 8.00.2055 (Intel X86) Dec 16 2008 19:46:53 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 2) it says 2000, so the alter database command to change compatibility level should work, rite?thnx |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-26 : 05:06:41
|
quote: Originally posted by jayram11 Microsoft SQL Server 2000 - 8.00.2055 (Intel X86) Dec 16 2008 19:46:53 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 2) it says 2000, so the alter database command to change compatibility level should work, rite?thnx
Nope. SQL 2000 is basically 80. 100 is SQL 2008. For SQL 2000, you can't change the compatibility level higher than 80.Anyway, since you are using SQL 2000, you should be posting your question under a SQL 2000 forum. And MERGE is not available under 2000. Where did you get that syntax from ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
jayram11
Yak Posting Veteran
97 Posts |
Posted - 2010-06-28 : 09:03:49
|
| i am using SQL server 2008 and the database was created under 2000 and i want to change the compatibility level to 100 for merge statement to workThnks |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-28 : 09:12:06
|
If you are using SSMS 2008 and querying a SQL Server 2008, this statement should workALTER DATABASE BRSDATASET compatibility_level = 100; N 56°04'39.26"E 12°55'05.63" |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-06-28 : 11:24:42
|
| But you shouldn't change compatibility level without retesting the whole application!If its just for DEV or some experiment then fine. If it is for DEV and you are going to deploy the changes to Production then you'll need a complete regression test. Or cross-your-fingers-and-hope. |
 |
|
|
jayram11
Yak Posting Veteran
97 Posts |
Posted - 2010-06-28 : 15:56:58
|
| so i am not going to use the merge statement rather use the update statement to update the records based on join.....wanted to use the Merge anywayssss |
 |
|
|
|