Our sysadmin renamed several of our AD groups that we are using inSQL server. The SQL login still has the old name. Is there a way to syncronize AD and our SQL logins?
I have de-normalized table, something like
CODES
ID | VALUE
10 | A,B,C
11 | A,B
12 | A,B,C,D,E,F
13 | R,T,D,W,W,W,W,W,S,S
The job is to convert is where each token from VALUE will generate new record. Example:
CODES_TRANS
ID | VALUE_TRANS
10 | A
10 | B
10 | C
11 | A
11 | B
What is the best way to do it in PL/SQL without usage of custom pl/sql packages, ideally with pure SQL?
Obvious solution is to implement it via cursors. Any ideas?
I am on the latest version of VMWare Workstation. In my VMWareTools I have configrued an individual scriptfile (start.bat) to be started when the (guest) OS is booted. Unfortuantely it does not run when starting the guest system as intended.
When pressing "run now" it works
Running the script from CMD works as well
I have changed the service (VMWareTools service) to run under different users - no success
All Users (of the service) have had Administrator privileges
I have no idea what is going wrong. Maybe someone is having an idea ....
I'm in the process of learning SQL, and I need a way of verifying that my SQL queries are valid (i.e. no syntax errors). I also would like to check what results they yield on a test database of my choosing and structure.
I'm using embedded firebird in my C# .NET application, so I don't really have any tools to work with. Anyone have any tips? Perhaps there are SQL administrators/query IDEs out there that work with Firebird?
Is it possible to create a "tree resolver" in SQL?
I have a table:
ID Name Parent
1 a
2 b 1
3 c 1
4 d 3
Now I want aSQL query that returns:
ID PATH
1 /a
2 /a/b
3 /a/c
4 /a/c/d
Is this possible with SQL? It would make many things easier for me. Any help would really be appreciated!
how do i open/view for editing an uploaded filein php?
i have tried this but it doesn't open the file.
$my_file = 'file.txt';
$handle = fopen($my_file, 'r');
$data = fread($handle,filesize($my_file));
i've also tried this but it wont work.
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
$data = 'This is the data';
fwrite($handle, $data);
what i have in mind is like when you want to view an uploaded resume,documents or any other ms office files like .docx,.xls,.pptx and be able to edit them, save and close the said file.
edit: latest tried code...
<?php
// Connects to your Database
include "configdb.php";
//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM employees") or die(mysql_error());
//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
//Echo "<img src=localhost/uploadfile/images".$info['photo'] ."> <br>";
Echo "<b>Name:</b> ".$info['name'] . "<br> ";
Echo "<b>Email:</b> ".$info['email'] . " <br>";
Echo "<b>Phone:</b> ".$info['phone'] . " <hr>";
//$file=fopen("uploadfile/images/".$info['photo'],"r+");
$file=fopen("Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt","r") or exit("unable to open file");;
}
?>
i am getting the error:
Warning: fopen(Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/uploadfile/view.php on line 17
unable to open file
the file is in that folder, i don't know it wont find it.
In sql server, we can issue sql to get data like
select * from table where column like '%myword%'
select * from person where Soundex(LastName) = Soundex('Ann')
what's the linq query to match above sql?
I have 2 Virtual Machines,
One with MS SQL server 2008 R2, other with MS SQL Server 2012 Express....
On 1 I have configuration for replication (publication), and I would like to setup Express version like subscriber.
but I can't to connect to publisher
SQL Server replication requires the actual server name to make a
connection to the server. Specify the actual server name, 'XXXX'.
(Replication.Utilities)
I have tried to cheat and added XXXX server name to hosts file, but it dos't help.
Additianlly I used to run http://www.hagrin.com/332/fixing-sql-server-replication-requires-actual-server-name-make-connection-server-error action for setup publication in correct way
What I need to do for successful connection ?
Is it possible to connect to aSQL Server Express 2008 database in ASP.NET with a server name of (local) like "server=(local);integrated security=SSPI;database=DBNAME"?
I'm working with another developer on a project and it's getting annoying having to have 2 different version of web.config because he is using SQL Server 2008 and (local) works, but I can't seem to get it to work with SQL Server 2008 Express locally.
The database is located on the same computer as the .NET code in case that matters.
Thanks.
Hi All,
Hope you can help.
Is there a way to reliably detect when a stored proc is being run on SQL Server without altering the SP itself?
Here's the requirement. We need to track users running reports from our enterprise data warehouse as the core product we use doesn't allow for this. Both core product reports and a slew of in-house ones we've added all return their data from individual stored procs.
We don't have a practical way of altering the parts of the product webpages where reports are called from. We also can't change the stored procs for the core product reports. (It would be trivial to add a logging line to the start/end of each of our inhouse ones).
What I'm trying to find therefore, is whether there's a way inSQL Server (2005 / 2008) to execute a logging stored proc whenever any other stored procedure runs, without altering those stored procedures themselves.
We have general control over the SQL Server instance itself as it's local, we just don't want to change the product stored procs themselves.
Any one have any ideas? Is there a kind of "stored proc executing trigger"? Is there an event model for SQL Server that we can hook custom .Net code into?
(Just to discount it from the start, we want to try and make a change to SQL Server rather than get into capturing the report being run from the products webpages etc)
Thoughts appreciated
Thanks
can anyone give some reference for non-sql database query interface design pattern?
For sql-based database, the query can be achieved by combining the query token.
but for non-sql, how to design the query, given that the query could be very complex.
We're about to embark on some ASP.NET MVC development and have been using our own entity framework for years. However we need to support more than our entity framework is capable of and so I'd like to get some opinions about using MVC with a more robust framework. We have narrowed down or choices to either NHibernate (with the Fluent APIs) or LINQ to SQL.
Which framework lends itself best to MVC style development (I know SO uses LINQ to SQL)?
If we want to support SQL Server, Oracle, MySQL - does that exclude LINQ to SQL?
We’re a team of SQL Servers database developers. Our clients are a mixed bag of C#/ASP.NET, C# and Java web services, Java/Unix services and some Excel.
Our client developers only use stored procedures that we provide and we expect that (where sensible, of course) they treat them like web service methods.
Some our client developers don’t like SQL exceptions. They understand them in their languages but they don’t appreciate that the SQL is limited in how we can communicate issues.
I don’t just mean SQL errors, such as trying to insert “bob” into a int column.
I also mean exceptions such as telling them that a reference value is wrong, or that data has already changed, or they can’t do this because his aggregate is not zero.
They’d don’t really have any concrete alternatives: they’ve mentioned that we should output parameters, but we assume an exception means “processing stopped/rolled back.
How do folks here handle the database-client contract? Either generally or where there is separation between the DB and client code monkeys.
Edits:
we use SQL Server 2005 TRY/CATCH exclusively
we log all errors after the rollback to an exception table already
we're concerned that some of our clients won't check output paramaters and assume everything is OK. We need errors flagged up for support to look at.
everything is an exception... the clients are expected to do some message parsing to separate information vs errors. To separate our exceptions from DB engine and calling errors, they should use the error number (ours are all 50,000 of course)
Hi everybody:
I am writing a C++ application that needs to execute SQL queries inaSQL Server DB and I want to do it using SQL Server Native Client.
The MSDN documentation has no a full reference on it and has a few examples so I am looking for some site having more information on how to connect, execute queries and retrieve results using this API.
Do you guys know where can I more info on it?
Thanks in advance,
Ernesto
Hi,
I've an SQL database and I would like to do a query who show all the datas containing the sign "%". Normally, to find a character (for example: "z") ina database I use a query like this :
mysql_query("SELECT * FROM mytable WHERE tag LIKE '%z%'");
But here, I want to found the % character, but inSQL it's a joker so when I write:
mysql_query("SELECT * FROM mytable WHERE tag LIKE '%%%'");
It show me all my datas. So how to found the % character in my SQL datas ?
Thanks
Hey guys !
I'm ina bit of a pickle here. I have a TSQL script that does a lot of database structure adjustments but it's not really safe to just let it go through when something fails.
to make things clear:
using MS SQL 2005
it's NOT a stored procedure, just ascriptfile (.sql)
what I have is something in the following order
BEGIN TRANSACTION
ALTER Stuff
GO
CREATE New Stuff
GO
DROP Old Stuff
GO
IF @@ERROR != 0
BEGIN
PRINT 'Errors Found ... Rolling back'
ROLLBACK TRANSACTION
RETURN
END
ELSE
PRINT 'No Errors ... Committing changes'
COMMIT TRANSACTION
just to illustrate what I'm working with ... can't go into specifics
now, the problem ...
When I introduce an error (to test if things get rolled back), I get a statement that the ROLLBACK TRANSACTION could not find a corresponding BEGIN TRANSACTION.
This leads me to believe that something when REALLY wrong and the transaction was already killed.
what I also noticed is that the script didn't fully quit on error and thus DID try to execute every statement after the error occured. (I noticed this when new tables showed up when I wasn't expecting them because it should have rollbacked)
any help in this department is welcome
if more speficics are needed, ask!
greetz
i need to write a vba script that will find afile. the file could be in three different locations
how do i find where the file is?
the file must have a specific string as part of the file name
my file name could be 9424.bas or 9424a.esy or 9424_.bas or 9424...esy, i dotn know what the file name exactly is but i know the important characters 9424
Whats the best way to use aSQL DB along side a NoSQL DB? I want
to keep my users and other data in postgres but have some data that
would be better suited for a NoSQL DB like redis.
I see a lot of talk about switching to NoSQL but little talk on
integrating it with existing systems. I think it would be foolish to
throw the baby out with the bath water and ditch SQL all together,
unless it makes things easier to maintain and develop.
I'm wondering what the best approach is for relating data stored inSQL to my data in redis. I was thinking of something along the line of
this.
User object stored inSQL
Book object in redis, key sh1 hash of value, value is a JSON string
Relations stored in redis, key User.pk:books, value redis set of sha1's
Anyone have experience, tips, better ways?
I have my mind firmly wrapped around relational databases and how to code efficiently against them. Most of my experience is with MySQL and SQL. I like many of the things I'm hearing about document-based databases, especially when someone ina recent podcast mentioned huge performance benefits. So, if I'm going to go down that road, what are some of the mental steps I must take to shift from SQL to NO-SQL?
If it makes any difference in your answer, I'm a C# developer primarily (today, anyhow). I'm used to ORM's like EF and Linq to SQL. Before ORMs, I rolled my own objects with generics and datareaders. Maybe that matters, maybe it doesn't.
Here are some more specific:
How do I need to think about joins?
How will I query without a SELECT statement?
What happens to my existing stored objects when I add a property in my code?
(feel free to add questions of your own here)
I am writing a new multi-tenant WCF RIA application. I plan to have a shared database with separate SQL Server schema for each tenant. I would like to use NHibernate for object-ralational mapping.
Configuration of SQL Server schema in mapping classes doesn't help because it is static and would need one set of mapping classes for each tenant.
Is it possible to dynamically configure ISession which SQL Server schema should be used for mapping objects to tables?
I just started learning LINQ to SQL, and so far I'm impressed with the easy of use and good performance.
I used to think that when doing LINQ queries like
from Customer in DB.Customers where Customer.Age > 30 select Customer
Get all customers from the database ("SELECT * FROM Customers"), move them to the Customers array and then make a search in that Array using .NET methods. This is very inefficient, what if there are hundreds of thousands of customers in the database? Making such big SELECT queries would kill the web application.
Now after experiencing how actually fast LINQ to SQL is, I start to suspect that when doing that query I just wrote, LINQ somehow converts it to aSQL Query string
SELECT * FROM Customers WHERE Age > 30
And only when necessary it will run the query.
So my question is: am I right? And when is the query actually run?
The reason why I'm asking is not only because I want to understand how it works in order to build good optimized applications, but because I came across the following problem.
I have 2 tables, one of them is Books, the other has information on how many books were sold on certain days. My goal is to select books that had at least 50 sales/day in past 10 days. It's done with this simple query:
from Book in DB.Books where (from Sale in DB.Sales where Sale.SalesAmount >= 50 and Sale.DateOfSale >= DateTime.Now.AddDays(-10) select Sale.BookID).Contains(Book.ID) select Book
The point is, I have to use the checking part in several queries and I decided to create an array with IDs of all popular books:
var popularBooksIDs = from Sale in DB.Sales where Sale.SalesAmount >= 50 and Sale.DateOfSale >= DateTime.Now.AddDays(-10) select Sale.BookID;
BUT when I try to do the query now:
from Book in DB.Books where popularBooksIDs.Contains(Book.ID) select Book
It doesn't work! That's why I think that we can't use thins kinds of shortcuts in LINQ to SQL queries, like we can't use them in real SQL. We have to create straightforward queries, am I right?