Forum Widgets
Latest Discussions
SQL Server Collation
Hi Experts, I am doing cross database migration. source database characterset is ISO_1 (ISO 8859-1) and binary sorting. While checking equivalent collation in MS SQL, I found Latin1_General_BIN. Later, I checked that all 4 collations are equivalent to the source database characterset and sorting. Latin1_General_BIN Latin1_General_BIN2 Latin1_General_100_BIN2 Latin1_General_100_BIN2_UTF8 Could you share your expert advice on the difference between the above collations and which one is best?sljesra27Feb 09, 2025Copper Contributor43Views0likes2CommentsNeed a solution for a problem without using CURSOR
Hi there to all SQL gurus So, here is the scenario. I have a #temp table in one of my SQL stored procedures which has only 2 columns, say Customer ID and Profile ID, and it has the below data Customer ID Profile ID 100001 ABCD001 100001 ABCD002 100002 ABCD001 100002 ABCD002 100003 ABCD001 I need to write a query which selects only the Profile ID which is mapped to all the Customer IDs. In this case Customer ID 100001 and 100002 have both ABCD001 and ABCD002, but Customer ID 100003 has only Profile ID ABCD001, so, the output of the SQL should have only ABCD001. How do I do this without using a CURSOR? Would a CTE help? I am not very familiar with CTE, so if the solution is using a CTE, please give your suggestions in more detail. Thanks in advanceKrishnaGcebFeb 09, 2025Copper Contributor9Views0likes1CommentUsing XQUERY on complicated XML
Hi All, and thanks in advance for any help you can provide. I'm currently working on SSMS v20 and am trying to parse XML in SQL Server using XQUERY. I've looked at dozens of examples, tutorials, etc., but every one has such simplistic XML that I can't figure out how to do it on my more complicated (more levels) XML. Here is a sample of data in an XML column: <dcjis:DataExchange xmlns:dcjis="http://www.xfact.com/schemas/eopss/dcjis/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dcjis-ext="http://www.xfact.com/schemas/eopss/dot-ec/1.0/extension" xmlns:dot-ec="http://www.xfact.com/schemas/eopss/dot-ec/1.0/extension" xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:j="http://niem.gov/niem/domains/jxdm/4.0" xmlns:s="http://niem.gov/niem/structures/2.0"> <dot-ec:Vehicle s:id="vehicle1"> <nc:VehicleColorPrimaryCode>BLU</nc:VehicleColorPrimaryCode> <nc:ItemMakeName>VOLK</nc:ItemMakeName> <nc:ItemModelName>JETTA</nc:ItemModelName> <nc:ItemModelYearDate>2011</nc:ItemModelYearDate> <nc:VehicleCMVIndicator>false</nc:VehicleCMVIndicator> <nc:ConveyanceRegistration> <nc:ConveyanceRegistrationPlateIdentification> <nc:IdentificationID>194JM4</nc:IdentificationID> <nc:IdentificationExpirationDate> <nc:Date>2020-04-30</nc:Date> </nc:IdentificationExpirationDate> <j:DrivingJurisdictionAuthorityANSID20Code>MA</j:DrivingJurisdictionAuthorityANSID20Code> <nc:IdentificationJurisdictionFIPS10-4Code>US</nc:IdentificationJurisdictionFIPS10-4Code> </nc:ConveyanceRegistrationPlateIdentification> <dot-ec:VehiclePlateTypeCode>PAN</dot-ec:VehiclePlateTypeCode> <dot-ec:VehiclePlateTypeText>Passenger Normal</dot-ec:VehiclePlateTypeText> </nc:ConveyanceRegistration> <dot-ec:VehiclePassenger16PlusIndicator>false</dot-ec:VehiclePassenger16PlusIndicator> <dot-ec:HazMatPlacardDisplayedIndicator>false</dot-ec:HazMatPlacardDisplayedIndicator> <dot-ec:VehicleRegistrationUnknownIndicator>false</dot-ec:VehicleRegistrationUnknownIndicator> <nc:InsuranceCarrierName>GOVT EMPLOYEE INS</nc:InsuranceCarrierName> </dot-ec:Vehicle> </dcjis:DataExchange> Thanks.Solved0105Feb 08, 2025Copper Contributor75Views0likes7CommentsQuestions about converting date
I used a function to convert character to date and then do a calculation using datediff. ,CONVERT(DATETIME,CONVERT(CHAR,cs.LastCourseActivityDate)) AS Last_Course_Activity_Datetime ,case when m.CompletionStatusYear = 2023 then '2023-12-31 00:00:00.000' when m.CompletionStatusYear = 2024 then '2024-21-31 00:00:00.000 else null end as 'Census' WHEN CompletionStatusGroup <> 'Complete - Reported' AND DATEDIFF(DAY ,last_course_activity_datetime,census)< 90 then 'In_Training' However, for some reason, when I run the script, it gives me an error "Conversion failed when converting date and/or time". How can I fix this?kpan8Feb 07, 2025Copper Contributor46Views0likes3CommentsNeed help with an SQL query without using a cursor
Hi there to all SQL gurus So, here is the scenario. I have a #temp table in one of my SQL stored procedures which has only 2 columns, say Customer ID and Profile ID, and it has the below data Customer ID Profile ID 100001 ABCD001 100001 ABCD002 100002 ABCD001 100002 ABCD002 100003 ABCD001 I need to write a query which selects only the Profile ID which is mapped to all the Customer IDs. In this case Customer ID 100001 and 100002 have both ABCD001 and ABCD002, but Customer ID 100003 has only Profile ID ABCD001, so, the output of the SQL should have only ABCD001. How do I do this without using a CURSOR? Would a CTE help? I am not very familiar with CTE, so if the solution is using a CTE, please give your suggestions in more detail. Thanks in advanceKrishnaGcebFeb 07, 2025Copper Contributor4Views0likes0CommentsSQL Server 2019 End of Support
Hi all I tried contacting a few people about this including our Microsoft supplier but with little information. Can any give me an idea of costs for support of general bug fixes i.e. If we encounter a platform issue during this period, potentially after patching/upgrading application software will there be support from Microsoft (without charge and possible delay)?LpienaarFeb 06, 2025Copper Contributor13Views0likes0CommentsStore Procedure to capture changes to tables/column
I need help to develop a stored procedure that can capture changes to all tables/columns in a CDC-enabled SQL database (all the tables are also CDC-enabled). The database is on SQL 2016. Store these operational changes (INSERTS, UPDATES, DELETES) into another table. The procedure should also capture old value, new value, and the date/time the changes took place.Technical_Architect5Feb 04, 2025Copper Contributor73Views0likes5CommentsSQL Query is taking long time when using WHILE inside another WHILE loop. Please help
WHILE @LineDircurrent <= @LineDirCount BEGIN Create Table ##TempLinePatternSequence( [Id] int identity(1,1) not null, [SignId] uniqueidentifier NULL, [LineDirId] uniqueidentifier NULL, [PatternId] uniqueidentifier NULL, [StopNum] uniqueidentifier NULL, [Sequence] int null, [DistanceFromPrevious] float null ) SELECT @CurrentLineDirId = LineDirId, @CurrentPatternId = PatternId, @CurrentSignID = SignId FROM ##TARGETLineDir where id = @LineDircurrent INSERT INTO ##TempLinePatternSequence SELECT distinct [SignId], [LineDirId], [PatternId], [StopNum], [Sequence], [DistanceFromPrevious] FROM ##LinePatternSequence LPS WHERE LPS.LineDirId = @CurrentLineDirId AND LPS.PatternId = @CurrentPatternId AND LPS.SignId = @CurrentSignID order by lps.Sequence SELECT @RTcount = count(*) from ##TempLinePatternSequence --where PatternId in(67055,67053,67054) --Linedirid = 150780 SET @sequence = 1 SET @RTcurrent = 1 --SELECT * from #TempLinePatternSequence While @RTcurrent < @RTcount BEGIN INSERT INTO ##TargetRunTimes select DISTINCT MRT.RuntimesBandId, LPS.SignId, LPS.LineDirId, LPS.PatternId, LPS.StopNum, NULL,@sequence ,NULL,NULL,NULL,NULL,MRT.ExtId from ##TempLinePatternSequence LPS INNER JOIN ##RunTimes MRT ON LPS.LineDirId = mRT.LineDirId AND LPS.PatternId = mRt.PatternId AND LPS.SignId = mRt.SignId WHERE LPS.Id = @RTcurrent AND LPS.LineDirId = @CurrentLineDirId AND LPS.PatternId = @CurrentPatternId AND LPS.SignId = @CurrentSignID SET @RTcurrent = @RTcurrent + 1mrloganathanFeb 03, 2025Copper Contributor33Views0likes2CommentsHelp in processing calculation with hhmmss
I need help to provide the following Expected finished time in hhmmss (Expected_finished_in_hhmmss) and Expected finished datetime (Expected_date). Request: If 8% records have been processed in 4:8:40 hh:mm:ss on 2025-01-028 15:55:17 then when 100% records will be processed. I needs result in hhmmss and finishing time after calculation. We'll have to add hhmmss in datetime etc. Expected result: Processed_% processed_on processed_in_hhmmss Expected_finished_in_hhmmss Expected_Date 8 2025-01-28 15:15:17 4:8:40Kenny_GuaJan 30, 2025Copper Contributor46Views0likes2CommentsLost Schema
Dear Team, I am looking for an Old Schema from AdventureWorks, it contains Sales.SalesOrder Table, I will appreciate if anyone can help me with the exact backup, I don't know which of the earlier year that has it or if it's part of Access Database or Northwind Database, All I could remember is the name of the Table as quoted above. DapoEBdapoebJan 30, 2025Copper Contributor17Views0likes1Comment
Resources
Tags
- Data Warehouse64 Topics
- Integration Services58 Topics
- sql server46 Topics
- Reporting Services43 Topics
- SQL39 Topics
- Business Intelligence35 Topics
- Analysis Services29 Topics
- Business Apps22 Topics
- Analytics18 Topics
- ssms13 Topics