Our sysadmin renamed several of our AD groups that we are using in SQLserver. 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'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 a SQL 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!
In sqlserver, 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?
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.
Hi All,
Hope you can help.
Is there a way to reliably detect when a stored proc is being run on SQLServer 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 in SQLServer (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 SQLServer 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 SQLServer that we can hook custom .Net code into?
(Just to discount it from the start, we want to try and make a change to SQLServer rather than get into capturing the report being run from the products webpages etc)
Thoughts appreciated
Thanks
Is it possible to connect to a SQLServer 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 SQLServer 2008 and (local) works, but I can't seem to get it to work with SQLServer 2008 Express locally.
The database is located on the same computer as the .NET code in case that matters.
Thanks.
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 SQLServer, 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 SQLServer 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 in a SQLServer DB and I want to do it using SQLServer 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") in a 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 in SQL 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
I am using Spring's JdbcDaoSupport class with a DriverManagerDataSource using the MySQL Connector/J 5.0 driver (driverClassName=com.mysql.jdbc.driver). allowMultiQueries is set to true in the url.
My application is an in-house tool we recently developed that executes sql scripts in a directory one-by-one (allows us to re-create our schema and reference table data for a given date, etc, but I digress). The sql scripts sometime contain multiple statements (hence allowMultiQueries), so one script can create a table, add indexes for that table, etc.
The problem happens when including a statement to add a foreign key constraint in one of these files. If I have a file that looks like...
--(column/constraint names are examples)
CREATE TABLE myTable (
fk1 BIGINT(19) NOT NULL,
fk2 BIGINT(19) NOT NULL,
PRIMARY KEY (fk1, fk2)
);
ALTER TABLE myTable ADD CONSTRAINT myTable_fk1
FOREIGN KEY (fk1)
REFERENCES myOtherTable (id)
;
ALTER TABLE myTable ADD CONSTRAINT myTable_fk2
FOREIGN KEY (fk2)
REFERENCES myOtherOtherTable (id)
;
then JdbcTemplate.execute throws an UncategorizedSqlException with the following error message and stack trace:
Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [ THE SQL YOU SEE ABOVE LISTED HERE ];
SQL state [HY000]; error code [1005]; Can't create table 'myDatabase.myTable' (errno: 150); nested exception is java.sql.SQLException: Can't create table 'myDatabase.myTable' (errno: 150)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
and the table and foreign keys are not inserted.
Also, especially weird: if I take the foreign key statements out of the script I showed above and then place them in their own script that executes after (so I now have 1 script with just the create table statement, and 1 script with the add foreign key statements that executes after that) then what happens is:
tool executes create table script, works fine, table is created
tool executes add fk script, throws the same exception as seen above (except errno=121 this time), but the FKs actually get added (!!!)
In other words, when the create table/FK statements are in the same script then the exception is thrown and nothing is created, but when they are different scripts a nearly identical exception is thrown but both things get created.
Any help on this would be greatly appreciated. Please let me know if you'd like me to clarify anything more.
Whats the best way to use a SQL 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 in
SQL to my data in redis. I was thinking of something along the line of
this.
User object stored in SQL
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 am using a server with windows server 2008 r2 running on it to run my program. The CPU of the server is Intel xeon x5570 2.93GHz with 2 processors, 8 cores per processer.
However, I found that the cpu usage is almost always below 10% even I use 32 threads in my program. And I also found that sometimes the cpu usage could reach as high as 93% through the task manager when running my program and at that moment my program has processed over 1000 files per second while normally, it only processed over 50 files per second. However, this does not happen often.
I use tools downloaded from the internet to make sure no core sleeps when the server is on, nothing changed. Also, I edited the windows register to make sure that I, as an administer, have no cpu usage limit. But it changed nothing.
Is there anyway that I can make full use of my cpu? That is to say that each core runs a thread of my program and the total cpu usage could reach over 50% when I use a reasonable number of threads in my program.
Did this happen to anyone of you? And could you help me with this ?
Thank you!
I am writing a new multi-tenant WCF RIA application. I plan to have a shared database with separate SQLServer schema for each tenant. I would like to use NHibernate for object-ralational mapping.
Configuration of SQLServer 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 SQLServer schema should be used for mapping objects to tables?
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 in a 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 work on a project and want to use an ORM. What should I use: Linq to Sql or Entity Framework? Linq to Sql provides more opportunities, as I see, for example support for enumeration types. However, also it is said that, Linq to Sql was for playing and learning for Linq and future strategy of Microsoft lies on Entity Framework. So which one should I use?
I've just installed a fresh copy of Windows Server 2008 x64 with IIS7 and PHP (fast CGI). However, I'm noticing that after moving my web site from a similarly specified machine to this one, I'm getting issues.
The issue seems to be that randomly, as I'm clicking through the web pages being served, the browser will suddenly hang saying "waiting for mysite.com...".
Sometimes the page will then timeout, or finally resolve after 20 to 30 seconds, but maybe missing the CSS style sheet.
Very strange, as this is the only website installed on this new server, and only myself using/testing it. Server is installed in the same data centre below the old server.
Has anyone else had a similar problem? I tried increasing the max workers pool to 10 (from 1), but this has no effect. Seems to happen most frequently after 1 or 2 minutes of inactivity on the website, then trying to load/refresh a web page.
Many thank for any info and help.
Kind Regards,
Seb
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 a SQL 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?
Hello
I have created login account on my localhost\sql2008 Server (Eg. User123)
Mapped to Database (default)
Authentication Mode on SQLServer is set to both (Windows and SQL)
But login to SQLServer fails with following message (for User123)
Note: Have checked mutliple time that UserName / Password are typed in correctly
Error Details:
Login failed for user 'User123' (Net.SqlClient Data Provider)
Server Name : localhost\sql2008
Error Number: 18456
Severity : 14
State : 1
Line Number : 65536
any help on this please.
Thanks