Microsoft SQL Server

160K

Solutions

49K

Contributors

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi EE,

Is their a query that enables me to list all users for a specific database and the permissions?

Thank you.
0
Free Tool: SSL Checker
LVL 12
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

BEGIN    
SELECT		

			[LiveCoinOrderID],
			[Symbol],
			[Quantity],		 
			[TimeStamp] AS UPDATED
			FROM
(
     SELECT 
			[LiveCoinOrderID],
			[Symbol],
			[Quantity],			
            Max([TimeStamp]) over(partition by [TimeStamp] order by UPDATED desc) as MaxTimeStamp, 
            Row_Number() over(partition by [TimeStamp] order by UPDATED desc) as RowNumber
     FROM [dbo].[LiveCoinOrder]
	 WHERE [DBStatus] = 'New'
) 

			WHERE RowNumber = 1
END

Open in new window

0
I downloaded twilight.zip from the internet. It is an excel sheet able to calculate sunrise and sunset created by Keith Burnett. I took the VBA code and incorporated it in Ms Access. In MS access I created a world clock and now I want to be able to display the sunrise sunset times for the relevant time zone as well.

I tested the VBA code via the Immediate window and this gave the correct values for sunrise and sunset. I ‘am able to type a value for glat in the argument. For example 51.5.

Function Sunrise(ByVal day As Double, glat As Double, glong As Double, index As Integer, _
 Optional altitude) As Double

When I debug the function to check the value of variable glat it gives a value of 51,5. This is with my regional setting with the comma being decimal separator. If I repeat the same procedure for the English setting with the dot separator it states 51.5 in de debug window. In both cases if gives the correct value for sunrise.

I live in the Netherlands and the DOUBLE value gives me problems. I want to transfer the latitude and longitude to the function. When I type the value with the keyboard directly in the arguments of the sub it displays to correct values. However I want to transfer the value of a combobox’s column to the sub. If I change the column of the combobox to double it display the comma  where ms access obvious expects a dot.

I searched the internet and EE. Tried replace,  changing string to value and concatenated the coordinates to a dot value …
0
Hi,

I am running an ETL process that uses timestamp on the source to determine the changes. We have to use this method as the source data is located on a SQL server 2005 machine.
This method will increment the timestamp when any of the rows are changed. I am only extracting data from a small number of columns within the table.
For example I need the data on col1, col2, col3, col4 only. If the data changes only in col5, the ETL process extracts the rows those rows as well. It does not do anything with it once extracted but it seems like an unnecessary action.

Is it possible to extract only the rows in which changes to the columns I want to extract have changed and ignore the rows where other columns have changed?

Many thanks
0
Here is the query which works but need few tweaks

DECLARE @EndDate AS DATE = '20180219';
DECLARE @StartDate AS DATE = '20180212';

SELECT GuestName ,
       SentTo AS Property ,
       ArrivalDate ,
       ISNULL(Extendedto, DepartureDate) AS DepartureDate ,
       Roomno ,
       RoomTypeRouting AS RoomType ,
       ArrivalDate2 AS ArrivalDate2 ,
       ISNULL(Extendedto2, DepartureDate2) AS DepartureDate2 ,
       [Roomno2] ,
       [RoomTypeRouting2] ,
       ArrivalDate3 AS ArrivalDate3 ,
       ISNULL(Extendedto3, DepartureDate3) AS DepartureDate3 ,
       [Roomno3] ,
       [RoomTypeRouting3] ,
       ArrivalDate4 AS ArrivalDate4 ,
       ISNULL(Extendedto4, DepartureDate4) AS DepartureDate4 ,
       [Roomno4] ,
       [RoomTypeRouting4]
FROM   CORR
WHERE  (   DeleteRecord IS NULL
           OR DeleteRecord = 0 )
       AND ArrivalDate >= '2016-01-01'
       AND ArrivalDate <= @EndDate
       AND ISNULL(ExtendedTo, DepartureDate) >= @StartDate;

Open in new window



WHERE  (   DeleteRecord IS NULL
           OR DeleteRecord = 0 )
       AND ArrivalDate2 >= '2016-01-01'
       AND ArrivalDate2 <= @EndDate
       AND ISNULL(ExtendedTo2, DepartureDate2) >= @StartDate;

WHERE  (   DeleteRecord IS NULL
           OR DeleteRecord = 0 )
       AND ArrivalDate3 >= '2016-01-01'
       AND ArrivalDate3 <= @EndDate
       AND ISNULL(ExtendedTo3, DepartureDate3) >= @StartDate;

Open in new window



same for ArrivalDate4 , ExtendedTo4, DepartureDate4

The query needs to find results on these as well and not only

WHERE  (   DeleteRecord IS NULL
           OR DeleteRecord = 0 )
       AND ArrivalDate >= '2016-01-01'
       AND ArrivalDate <= @EndDate
       AND ISNULL(ExtendedTo, DepartureDate) >= @StartDate;

Cheers
0
Hello,
I have a query which works perfectly fine , but need an enhancement in it.
DECLARE  @EndDate AS DATE = '2018-02-19'
DECLARE @StartDate as date = '2018-02-12'


SELECT
      GuestName
    , format(ArrivalDate,'yyyy-MM-dd') ArrivalDate
    , format(CASE
                  WHEN Extendedto IS NULL THEN DepartureDate
                  ELSE Extendedto
           END,'yyyy-MM-dd') AS DepartureDate
                                   , SentTo AS Property, Roomno, RoomTypeRouting AS 'RoomType' 



,     format(ArrivalDate2,'yyyy-MM-dd') ArrivalDate2
,     format(CASE
                  WHEN Extendedto2 IS NULL THEN DepartureDate2
                  ELSE Extendedto2
             END,'yyyy-MM-dd') AS DepartureDate2
,     [Roomno2] 
,     [RoomTypeRouting2] 

,     format(ArrivalDate3,'yyyy-MM-dd') ArrivalDate3
,     format(CASE
                  WHEN Extendedto3 IS NULL THEN DepartureDate3
                  ELSE Extendedto3
            END,'yyyy-MM-dd') AS DepartureDate3
,     [Roomno3]
,     [RoomTypeRouting3]

,     format(ArrivalDate4,'yyyy-MM-dd') ArrivalDate4
,     format(CASE
                  WHEN Extendedto4 IS NULL THEN DepartureDate4
                  ELSE Extendedto4
             END,'yyyy-MM-dd') AS DepartureDate4 
,     [Roomno4] 
,     [RoomTypeRouting4] 
FROM CORR
WHERE ( DeleteRecord is null or DeleteRecord = 0) 
AND ArrivalDate >= '2016-01-01'
AND ArrivalDate <= @EndDate
AND COALESCE(ExtendedTo,DepartureDate) >= @StartDate

Open in new window


Need to display
1:
  [Roomno2]
,     [RoomTypeRouting2]  only when

WHERE ( DeleteRecord is null or DeleteRecord = 0)
AND ArrivalDate2 >= '2016-01-01'
AND ArrivalDate2 <= @EndDate
AND COALESCE(ExtendedTo2,DepartureDate2) >= @StartDate

2:
 
  [Roomno3]
,     [RoomTypeRouting3]  only when

WHERE ( DeleteRecord is null or DeleteRecord = 0)
AND ArrivalDate3 >= '2016-01-01'
AND ArrivalDate3 <= @EndDate
AND COALESCE(ExtendedTo3,DepartureDate3) >= @StartDate

Similar for  [Roomno4] ,RoomTypeRouting4]


Any suggestions are appreciated!
Thanks
0
trying to use rank over partition with a join and am failing.  the following query works but when i try to only select the rows where the rank is 1, it doesnt recognize dog as a column

the working querry
select RANK () OVER (PARTITION BY B.ACCOUNTKEY ORDER BY B.ADDDTTM DESC) AS DOG ,* from billing.account A
INNER JOIN BILLING.BILL B
ON A.ACCOUNTKEY = B.ACCOUNTKEY

the query that doesnt work and returns dog as an unrecognized column
select RANK () OVER (PARTITION BY B.ACCOUNTKEY ORDER BY B.ADDDTTM DESC) AS DOG ,* from billing.account A
INNER JOIN BILLING.BILL B
ON A.ACCOUNTKEY = B.ACCOUNTKEY
 where DOG = 1

the error is "invalid column name 'DOG'
can someone help
0
is there a way to consolidate results into a single cell, i want only one line per 'SignalID' unfortunatly the table SigLog as described below, has many entries  per 'SignalID' i would like to consolidate each entry from Siglog.faction that contains a 7 or 10 digit phone number as one cell in my results, instead of a separate row for each entry.
i don't know how to approach this.
SELECT DATEADD(HOUR, -6, SignalHistory.AlarmDate) AS [Alarm Date], 
       ISNULL(Subscriber.AcctLineCode, 'XX') AS LC, 
       Subscriber.AcctNum, 
       Subscriber.Name, 
       Codes.Description, 
       SignalHistory.AlarmZones AS [Zone #], 
       ISNULL(Zones.Description, '') AS [Zone Description], 
       Subscriber.Address, 
       Subscriber.City, 
       Subscriber.State, 
       SignalHistory.RawData,
       Subscriber.MainPhone,
       MISC.Disposition,
       siglog.fAction
FROM [History0218].[dbo].[SignalHistory] SignalHistory
LEFT JOIN [MISCELLANEOUS].[dbo].[Dispositions] MISC       ON SignalHistory.DispositionID = MISC.DispositionID
LEFT JOIN [SUBSCRIBER].[dbo].[Subscriber Data] Subscriber ON SignalHistory.AccountID = Subscriber.AccountID
LEFT JOIN [History0218].[dbo].[SignalLog] siglog          ON SignalHistory.SignalID = siglog.SignalID 
LEFT JOIN [SUBSCRIBER].[dbo].[Zone Lists] Zones           ON SignalHistory.AccountID = Zones.AccountID 
                                                          AND LTRIM(SignalHistory.AlarmZones) = LTRIM (Zones.Number)
                   

Open in new window

0
I am working with a database admin. She needs me to create a CNAME on our DNS server that points to a specific "instance" on a SQL server. I created a basic CNAME and pointed it at the server where SQL is installed but it right now she sees it as pointing to the default instance. I am not a SQL person, but is there a way for me to create a CNAME or even a HOST entry and point it to a specific instance within a SQL server? Not just the server itself? We are using Windows 2012 and SQL 2012.
0
Hello Everyone,

I have a SQL query and I know this is just simple one but for some reasons I cannot get it to work.

What I want to accomplish is if there are 2 more columns with the same values from Column1 to Column 3 but not the same value with Column4, then add new column and insert Column4 2nd output value into NewColumn.

Is this possible or any suggestions is appreciated.

Thank you again for all your help. I really appreciate it.

See attached.
SQLTest.xlsx
0
Learn to develop an Android App
LVL 12
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

I have a query that gives me row count, totalpages, usedpages, totalspace, usedspace, and dataspace of all the tables in my database.

what is the difference between dataspace and usedspace

for example.  i have one table that has the following statistics.  
3.3 gigs of totalspace, 3.3 gigs of usedspace and then only 30 megs of dataspace

why is dataspace so much smaller than used space

below is the query
SELECT
t.NAME AS TableName,
i.name as indexName,
p.[Rows],
sum(a.total_pages) as TotalPages,
sum(a.used_pages) as UsedPages,
sum(a.data_pages) as DataPages,
(sum(a.total_pages) * 8) / 1024 as TotalSpaceMB,
(sum(a.used_pages) * 8) / 1024 as UsedSpaceMB,
(sum(a.data_pages) * 8) / 1024 as DataSpaceMB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME NOT LIKE 'dt%' AND
i.OBJECT_ID > 255 AND
i.index_id <= 1
GROUP BY
t.NAME, i.object_id, i.index_id, i.name, p.[Rows]
ORDER BY
object_name(i.object_id)
0
I have the following query
SELECT DATEADD(HOUR, -6, SignalHistory.AlarmDate) 'Alarm Date', 
       IsNull(Subscriber.AcctLineCode, 'XX') AS LC, Subscriber.AcctNum, Subscriber.Name, Codes.Description, SignalHistory.AlarmZones as 'zone #', IsNull(Zones.Description, '') AS 'Zone Description', Subscriber.Address, Subscriber.City, Subscriber.State, SignalHistory.RawData
FROM [History0218].[dbo].[SignalHistory] SignalHistory
   LEFT JOIN [SUBSCRIBER].[dbo].[Subscriber Data] Subscriber ON SignalHistory.AccountID = Subscriber.AccountID
   LEFT JOIN [SUBSCRIBER].[dbo].[Zone Lists] Zones ON SignalHistory.AccountID = Zones.AccountID AND LTRIM(SignalHistory.AlarmZones) = LTRIM (Zones.Number)
   LEFT JOIN [MISCELLANEOUS].[dbo].[Signal Codes] Codes ON SignalHistory.AlarmCode = Codes.Code
WHERE SignalHistory.AlarmDate >= DATEADD(HOUR, -1, GETUTCDATE())AND (Subscriber.AcctLineCode ='DS'OR Subscriber.AcctLineCode ='DSA')
ORDER BY AlarmDate DESC

Open in new window

I now have one more table I need to reference, to add one more column to my results, and i'm not sure how to get the result i am looking for....
the new table is in [subscriber] and it is dbo.Subscriber status. this of course has the standard key 'AccountID' in it
what i need to do is check this table for 2 columns, A 'TestStart' column and a 'TestEnd' column, if the 'AlarmDate' fits within the test window for the 'AccountID' i need to have a column that states weather each line matches.

Im assuming I will have to add another left join
(AlarmDate >= [TestStart] AND AlarmDate  <= [TestEnd]) = yes
0
hi experts

the column store [Fe creac  ]
Column 0	Usuarios    	Grupo	Tipo          	Creado por  	Fe creac  	Válido de 	Fin valid 	Entr sist 1  	Entr sist 2	Clave acc 1	Clave acc 2	Bloqueo1	Bloqueo2                                       	EntrSisInc	Column 15
	A_MATERIALES	     	A Diálogo     	ATI         	14.11.2016	          	          	20.02.2018  	07:18:10  	          	15.11.2017	       	                                              	          	
	AABARCA     	     	A Diálogo     	SMIADMIN    	31.01.2012	          	          	17.02.2018  	10:12:30  	          	18.12.2017	       	                                              	          	
	AAGUILAR    	     	A Diálogo     	SMIADMIN    	28.11.2011	          	          	19.02.2018  	11:01:50  	          	15.12.2017	       	                                              	          	
	AAROCA      	     	A Diálogo     	SMIADMIN    	13.12.2013	          	          	20.02.2018  	08:12:10  	          	06.02.2018	       	                                              	          	
	ABALLADARES 	     	A Diálogo     	ATI         	17.07.2017	          	          	04.08.2017  	18:32:07  	          	18.07.2017	       	Responsable                                   	          	

Open in new window


this query has errors
SELECT*
  FROM [SMI].[dbo].[rsusr200_20022018_1335]
  where CAST([Fe creac  ] AS datetime)   >=  CAST('01.10.2017' AS datetime)

Msg 242, Level 16, State 3, Line 2
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
0
I have a stored procedure that functions fine as long as the @userTypes parameter contains something like '100,200,300,400,500' - but how can I branch out the WHERE clause to also allow '%', as the CSVToTable doesn't handle that of course, and throws an error :) ?

WHERE  userRole like @uRole AND userType IN (SELECT * FROM dbo.CSVToTable(@userTypes))

Open in new window


I've tried with this, but still get an error:

WHERE  userRole like @uRole AND userType IN (CASE @userTypes WHEN '%' THEN userType ELSE (SELECT * FROM dbo.CSVToTable(@userTypes)) END)

Open in new window

0
I need to write a SP to delete rows that have a timestamp 7 days or older from this table..

--IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[LiveCoinAllOrderBookBids]') AND type in (N'U'))
--DROP TABLE [dbo].[LiveCoinAllOrderBookBids]
--GO
--IF NOT EXISTS (select * from INFORMATION_SCHEMA.tables where TABLE_NAME = 'LiveCoinAllOrderBookBids')
--BEGIN
--CREATE TABLE [dbo].[LiveCoinAllOrderBookBids](
--	[LiveCoinAllOrderBookBidsID] [int] IDENTITY(1,1) NOT NULL,
--	[LiveCoinAllOrderBookID] [int] NOT NULL,
--	[BidQuantity] DECIMAL(18,8) NOT NULL,
--	[Bid] DECIMAL(18,8) NOT NULL,
--	[TimeStamp] BIGINT NOT NULL,			 
--	CONSTRAINT [PK_LiveCoinAllOrderBookBids] PRIMARY KEY CLUSTERED 
--	(
--		[LiveCoinAllOrderBookBidsID] ASC
--	))	
--END
--GO

Open in new window

0
Can somebody show me the correct way to write this SP?

IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID(N'[dbo].[usp_LiveCoinAddAllOrderBookReturnID]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[usp_LiveCoinAddAllOrderBookReturnID];
GO
CREATE PROCEDURE [dbo].[usp_LiveCoinAddAllOrderBookReturnID]
(
		   @ExchangeID INT,
		   @Symbol NVARCHAR(128),           
		   @LiveCoinAllOrderBookID INT OUTPUT
)
AS
BEGIN
IF NOT EXISTS (SELECT * FROM [dbo].[LiveCoinAllOrderBook] WHERE [symbol] = @Symbol)
INSERT INTO [dbo].[LiveCoinAllOrderBook]
(
		
		   [ExchangeID],
		   [Symbol]
)
VALUES
(
		   @ExchangeID,
           @Symbol
)

SELECT @LiveCoinAllOrderBookID = @@IDENTITY

ELSE

SELECT LiveCoinAllOrderBookID FROM [dbo].[LiveCoinAllOrderBook] WHERE [symbol] = @Symbol

END
GO

Open in new window

0
I would like to update a field in my system with a value from an excel file
The excel file is called Hull Equip and it contains two columns Equipment No (which contains the existing values) and New Equip No (which contains the new number)
The table I am trying to update is called EQUIP and the field is called EQNUM
How would the query look?
Gordon
0
Hi,

In MS-SQL database, we are storing all longitude_degrees, latitude_degrees values for passing vessels. In map draw polygon and trying to select the vessels included in that polygon coordinates.

query :

select longitude_degrees, latitude_degrees  from [ Table ] where Geometry::STGeomFromText('POLYGON((103.47718811035156 1.2504558563232422,103.47982025146484 1.2505289316177368,103.49195098876953 1.249359369277954,103.49137115478516 1.2449731826782227,
103.49049377441406 1.2444614171981812,103.48983001708984 1.2444614171981812,103.48551940917969 1.2444614171981812,103.47762298583984 1.2444614171981812,103.47002410888672 1.2444614171981812,103.47718811035156 1.2504558563232422,103.47718811035156 1.2504558563232422,
103.47718811035156 1.2504558563232422))',4326)
.STContains(Geometry::STPointFromText('POINT(' + CAST([longitude_degrees] AS VARCHAR(20)) + ' ' + CAST([latitude_degrees] AS VARCHAR(20)) + ')',0)) = 1

I have used STIntersects and STEquels function also but no records selected.

My expectation is need to get the  vessels inside that polygon as i selected in map.


Please help me to resolve the  problem.



Thanks,
Venkat.
0
I have an attendance table in SQL Server 2012 named tblOrgHours. (attached)  This is where I log all my attendance for different agencies in tracking how many hours each activity has been performed each day by different kids.  The ActivityID in this table is relational with tblOrgActivity. (attached)  The RegID in that same table is relational with the student information found in table tblOrgRegistrations. (attached)  I need to create an sql query that will output unduplicated counts of the kids who had greater than 0 hours of service during a specified period of time.  The unduplicated demographic counts are broken out as you see in the attached output file.  

After looking at my output, how is is possible to get all this information pulled up from one sql query?
tblOrgHours.xlsx
tblOrgActivities.xlsx
tblOrgRegistrations.xlsx
Output-Example.xlsx
0
Keep up with what's happening at Experts Exchange!
LVL 12
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Hello,

I have an macro and spreadsheet that contains the following columns: studentname, course, startdate, enddate and enrollmentstatus. I have a Microsoft SQL Server stored procedure that evaluates each row in the Excel spreadsheet. If today's date is between the startdate and enddate then the enrollment status is set to "ActiveEnrollment". If today's date is less than the startdate or today's date is greater than the enddate then the enrollmentstatus is set to "InactiveEnrollment". If the startdate field is empty in Excel then I want to return "RegistrationIncomplete".

The stored procedure can evaluate the startdate and enddate cells if there is a date. However, I am not able to code the stored procedure to properly evaluate the empty cell.

I have included a script with the stored procedure (studentcoursevalidation) and a table (StudentCourseEnrollment). Also attached is the Excel Spreadsheet with the macro.

I would appreciate assistance in finding out how to properly evaluate an empty cell in Excel using a SQL Server stored procedure.

Thanks in advance.
Sample_Table_Setup_StoredProc.sql
Sample_Spreadsheet_1.xlsm
0
I am fairly new to SQL Server and the statement syntax

I have data that was bulk loaded into a SQL table 'SQNA_NameAddress_BulkLoad'  There is only 1 field defined in that table 'NABulkLoad nchar(130).

I now want to break apart the individual fields into table 'SQNA_NameAddress_Import'.  This is the definition of SQNA_NameAddress_Import
CREATE TABLE [dbo].[SQNA_NameAddress_Import](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ControlNumber] [int] NULL,
	[SequenceNumber] [int] NULL,
	[AddrLine1] [nvarchar](30) NULL,
	[AddrLine2] [nvarchar](30) NULL,
	[AddrLine3] [nvarchar](30) NULL,
	[AddrLine4] [nvarchar](30) NULL,
 CONSTRAINT [aaaaaSQNA_NameAddress_Import_PK] PRIMARY KEY NONCLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

Open in new window


IN the bulk record the fields contained are
Pos 1 - 7            ControlNumber
Pos 8 - 10          SequenceNumber
Pos 11 - 40        AddrLine1
Pos 41 - 70        AddrLine2
Pos 71 - 100      AddrLine3
Pos 101 - 130    AddrLine4

It would seem that I could do this with a insert statement that pulls pieces of the bulk import record and loads them directly into the 'Import' table but I'm not sure how to do that.

I think it would be something like this but I know the substring syntax isn't even close.

Insert Into SQNA_NameAddress_Import ( ControlNumber, SequenceNumber, AddrLine1,AddrLine2, AddrLine3, AddrLine4 )
                                                                         w.substring(NABulkLoad, 1,7) .............

From SQNA_NameAddress_BulkLoad w

Does anyone know the syntax that would work?
0
Was hoping soemone might tell me if I'm interpreting this perfmon graph properly,
as it related to SQL server counters..
In the following graphic, you can see the 2 counters I'm capturing, for purposes of seeing SQL server I/O for Reads/Writes needing to go to Disk, instead of getting them from buffer memory.
My question is, since I've set the vertical scale to 100, and the counters are both displaying in ms, is it correct to say the Avg Disk sec/Write(in RED) is mostly
staying below 10ms?
and the Reads(in BLUE) are mainly above 10ms, even going off the chart a few times..?
In this sql
0
ejemplo.xlsxHi, experts

I need your help with a sql server programming theme, specifically with the transformation of flat records into a hierarchical structure.

I have this table with the following information

id_tab      id_nivel      cod_nivel      des_nivel
1      0      TOT SEL      SELECTED TOTAL
2      1      16      G01C0+A2 (DIVANON)
3      2      G01B0      ANTIFUNGICOS GINECOLOG
4      3      CLOMA      CLOMAZOL 3         ECU
5      4      01409      Manta
6      4      03252      Santo Domingo
7      4      01307      Babahoyo
8      4      01242      G:J.Cornel,Quito,Urdanet,Boyac
9      4      03502      Esmeraldas
10      4      01200      G: Urb. 12 de Octubre
11      3      VAGIL      VAGIL C ROWE       RWE
12      4      01409      Manta
13      4      03252      Santo Domingo
14      4      01242      G:J.Cornel,Quito,Urdanet,Boyac
15      4      02104      C:Las Americas,CC.Vega,Vinueza
16      4      01523      M:Machala(sur) 25 Jun.y Palmer
17      4      01614      Milagro
.......

and I need to transform it into this

id_tab      id_nivel_1      cod_nivel_1      des_nivel_1      id_nivel_2      cod_nivel_2      des_nivel_2      id_nivel_3      cod_nivel_3      des_nivel_3      id_nivel_4      cod_nivel_4      des_nivel_4
1      1      16      G01C0+A2 (DIVANON)      2      G01B0      ANTIFUNGICOS GINECOLOG      3      CLOMA      CLOMAZOL 3         ECU      4      01409      Manta
2      1      16      G01C0+A2 (DIVANON)      2      G01B0      ANTIFUNGICOS GINECOLOG      3      CLOMA      CLOMAZOL 3         ECU      4      03252      Santo Domingo
3      1      16      G01C0+A2 (DIVANON)      2      G01B0      ANTIFUNGICOS GINECOLOG      3      CLOMA      CLOMAZOL 3         ECU      4      01307      Babahoyo
4      1      16      G01C0+A2 (DIVANON)      2      G01B0      ANTIFUNGICOS GINECOLOG      3      CLOMA      CLOMAZOL 3         ECU      4      01242      G:J.Cornel,Quito,Urdanet,Boyac
5      1      16      G01C0+A2 (DIVANON)      2      G01B0      ANTIFUNGICOS GINECOLOG      3      CLOMA      CLOMAZOL 3 …
0
I am trying to write a query to update a "Comment" field on some records. Part of the Comment field needs to include a date from another column in each record.

For example, for the record below, I'd like to write a query that changes the comment to: "This record was created on [CreatedDate] and passed inspection."

Can someone assist?

ID   |     Comment     |     CreatedDate
-------------------------------------------------------
1     |                           |     1/18/2018
0
Hi,

I am trying to create a linked server on SQL Server 2016 to connect with a SQL Server 2005 server. I keep getting the standard network error/check server name message.
Any guidance on creating this would be appreciated

Many thanks
0

Microsoft SQL Server

160K

Solutions

49K

Contributors

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.