If I've understood your question properly, you're looking to concatenate row values rather than PIVOT them.
This article[^] covers most of the options. For example, the black-box XML method:
SELECT',' + Site
FROM YourTable As I
WHERE I.DataPoint = O.DataPoint
FOR XML PATH(''), TYPE
-- Remove the first comma:
, 1, 1, ''
) As Sites
YourTable As O
Thank you, but, no. Not concatenation.
I need the CH and KC to be the column headers.
What I have is 1400 data points and 4 sites; in theory, all sites SHOULD have the same datapoints, but... they don't.
I need to create a matrix of datapoints and sites to show what is there and what isn't.
What I've presented is the simplified version, but the concept is correct.
Could you help with XML select. Below is my xml however it won't select correct value.
DECLARE @input AS XML
SET @input =N'<?xml version="1.0" encoding="utf-16"?><NewDataSet><GroupID>111111</GroupID><GroupID>111111</GroupID><GroupID>999999</GroupID><GroupID>777777</GroupID></NewDataSet>'SELECT
Ppl.GroupID.value('(@GroupID)', 'VARCHAR(6)') AS'GroupID'FROM
@input.nodes('/NewDataSet/GroupID') as Ppl(GroupID)
as (select p.ID_Pelanggan
,casewhen p.Status_Pelanggan=2 then'Aktip'else'Non Aktip'end'Status'from PELANGGAN p),
as (select g.ID_Pelanggan
from GANTI_Log g)
from pel p leftouterjoin ganti g
I have a table ID, Lock and other fields. I have a VB.NET program that gets the TOP 1 record that is not lock and lock that record to be keyed/entry. Multiple users will use this program, is it possible that more than one user can access the same record in this process? Its possible users will request a record at the same time.
Lets say that 2 computer are using same program connecting to the same server database
Client:1 - Request Time: 10:30:00 will get the ID 1, ID 1 will lock(update to true)
Client:2 - Request Time: 10:30:05 will get the ID 2, ID 2 will lock(update to true) - cause ID 1 is lock
This is my question. same request
Client:1 & 2 - Request Time: 10:30:00
- Query is (SELECT TOP 1 * FROM Table WHERE Lock = False)
- Put ID to a variable
- In the above run time, Is the 2 client will get the ID 1 or the this query will stack on SQL Server will finish one query first before executing another query?
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
- Most of the problem in your life are due to two reasons: you act without thinking, or think without acting
is it possible that more than one user can access the same record in this
Probably. Does not mean that it will be a problem.
There's a lot of stuff written on locking in SQL, with topics like lost updates[^] and dirty reads (no, not those magazines). You can add various hints[^] to the query. MSDN has dedicated a section[^] to consistency and concurrency.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
If I understood your question correctly, you're wondering if session 1 can read the data that session 2 is locking. If this is the concern then the answer in many cases is no.
Consider the following scenario:
Session 1 Session 2
Select record A, field named SomeValue is 1
Select record A, field named SomeValue is 1
Update record A,
field named SomeValue is set to 2,
an eXclusive lock is taken
Select record A, record is locked, session 2 waits
Some other modifications
Session 2 still waits
Commit the transaction, lock is freed
Session 2 now gets the answer,
field named SomeValue is 2
(the value session 1 updated)
Now the actual sequence varies depending if auto-commit is on and so on. Also you should know that if row versioning is in effect, then the behaviour is far different. For more information, read Data versioning in SQL Server using row versions[^]
I have created an application that use a sql server database.
But the problem is that a user can open sql server management studio and can do anything that I don't like , for example :
1) Can modify values inside tables.
2) can delete records
3) Can see and can get my database structure.....
How can I protect my database , so that users can modify this database only inside my application , and can do anything outside my application ? I don't know does exist a way to protect my database with a password or.... ??? for example when I was using Access for database , i have protected Access files with a password , and after only my application can open this database .
Is possible to include a protection in the sql server database file ( so even the file is imported to another computer to remain protected ?
I have a specific situation :
My application is designated to manage several "office".
In my application folder , i have a empty backup file ( offline) of my database called "Model". And inside my application a user can create "A new office " and when he do this the application restore a copy of "Model" inside sql server with a specific name (for example "Office1". Another time the user can create another "Office" using again a copy of "Model"
So inside Sql server may be different databases ( all of them with the same structure ) like "Model"
So in this situation how can i Protect my databases and the "Model" .
Because i think i should apply a Protection" inside the offline backup file "Model" ( if it's possible , all the databases that have created from "Model" will have the protection ) or ??????