Is there an easy way to do a find and replace on a string in every view and stored procedure in my SQL Server database.
I need to replace something like 'X United Kingdom' with 'X(UK)'.
i am going on a job interview and have zero experience with ms sql, however i have 1 year with oracle. is there such a huge difference between the two? what programming questions can i expect?
i have two tables
table1 fields
fid,fname,fage
a ,abc ,20
b ,bcv ,21
c ,cyx ,19
table2 fields
rcno,fid,status
1 ,a ,ok
2 ,c ,ok
3 ,a ,ok
4 ,b ,ok
5 ,a ,ok
i want to display rectors like this
fid from table1 , count(recno) from table 2 and fage from table1
fid,count(recno),fage
a ,3 ,20
b ,2 ,21
c ,1 ,19
i try many sql queries but got error
Thanks
I need to get a list of all tables that are published for replication from MS-SQL 2005/2008 databases. Is there a system stored procedure or a query I could run to generate such a list?
Thank you,
Hi Friends,
I need to run a profiler on SQL 2005 to capture the SPs with which took longer than 1/10th of a second. Can you please let me know how can I do that. I dont see the option. Also in the duration is that measured in second or minute.
I would apprecaite your help.
Thanks,
I have table with 3 columns(smallint) in MS SQL 2005.
Table Ratings
ratin1 smallint,
ratin2 smallint
ratin3 smallint
These columns can have values from 0 to 5
How to select average value of these fields, but only compare fields where value is greater then 0.
So if column values are 1,3,5 - average had to be 3
if values are 0,3,5 - average had to be 4
I have created a table with the following structure-
$sql = "CREATE TABLE followers
(
uid int UNSIGNED NOT NULL UNIQUE,
PRIMARY KEY(uid),
follower_count int UNSIGNED ,
is_my_friend bool,
status_count int UNSIGNED,
location varchar(50)
)";
I need to find the uid of the person with max(status_count+follower_count) and whose is_my_friend = 1
I wrote the following query but I ain't getting the correct uid.
SELECT p.uid FROM (select uid,is_my_friend,max(follower_count+status_count) from followers) p WHERE p.is_my_friend = 1;
We have been having problems with ghost updates in our DB (SQL Server 2005) fields are changeing and we cannot find the routine that is updating. Is there a way using an update trigger (Or any other way) to tell what caused the update?
I have problem using IIS 7 and SQL Server 2008. When I trying to show my website using IIS as webserver I get the message "[SqlException (0x80131904): Login failed for user..."
When I using the webserver included in Visual Studio 2010 to show same website there is no problem to access the database.
Why is it working with VS2010 webserver but not with IIS?
SELECT COUNT(*) AS Expr1
FROM Book
INNER JOIN Temp_Order ON Book.Book_ID = Temp_Order.Book_ID
WHERE (Temp_Order.User_ID = 25)
AND (CONVERT (nvarchar, Temp_Order.OrderDate, 111) = CONVERT (nvarchar, GETDATE(), 111))
In here i want to change my User_ID to get from a label.Text
this Sql Statement is in a DataView. so in the Wizard it not accepting a text box values or anything.
can someone please help me to solve this
I am trying to fetch records based on two dates from sql server...
Select * from table where CreatedDate between @StartDate and @EndDate and i pass 5/12/2010 and 5/12/2010 (ie) fetching records for today... I have 17 records dated 5/12/2010 but none seems to get selected....
EDIT:
I use this but when i debug my value it shows 5/12/2010 12:00:00AM
DateTime baseDate = DateTime.Today;
var today = baseDate;
GetBookingReportByDate(today,today);
Welcome to the first ever post on the brand new Red Gate Business Intelligence Tools Team blog!
About the team
Nick Sutherland (product manager): After many years as a software developer and project manager, Nick took an MBA and turned to product marketing. SSAS Compare is his second lean startup product (the first being SQL Connect). Follow him on Twitter.
David Pond (developer): Before he joined Red Gate in 2011, David made monitoring systems for Goodyear. Follow him on Twitter.
Jonathan Watts (tester): Jonathan became a tester after finishing his media degree and joining Xerox. He joined Red Gate in 2004. Follow him on Twitter.
James Duffy (technical author): After a spell as a writer in the video game industry, James lived briefly in Tokyo before returning to the UK to start at Red Gate.
What we're working on
We launched a beta of our first tool, SSAS Compare, last month. It works like SQL Compare but for SSAS cubes, letting you deploy just the changes you want. It's completely free (for now), so check it out. We're still working on it, and we're eager to hear what you think.
We hope SSAS Compare will be the first of several tools Red Gate develops for BI professionals, so keep an eye out for more from us in the future.
Why we need you
This is your chance to help influence the course of SSAS Compare and our future BI tools. If you're a business intelligence specialist, we want to hear about the problems you face so we can build tools that solve them. What do you want to see? Tell us!
We'll be posting more about SSAS Compare, business intelligence and our journey into BI in the coming days and weeks. Stay tuned!
Welcome to the first ever post on the brand new Red Gate Business Intelligence Tools Team blog!
About the team
Nick Sutherland (product manager): After many years as a software developer and project manager, Nick took an MBA and turned to product marketing. SSAS Compare is his second lean startup product (the first being SQL Connect). Follow him on Twitter.
David Pond (developer): Before he joined Red Gate in 2011, David made monitoring systems for Goodyear. Follow him on Twitter.
Jonathan Watts (tester): Jonathan became a tester after finishing his media degree and joining Xerox. He joined Red Gate in 2004. Follow him on Twitter.
James Duffy (technical author): After a spell as a writer in the video game industry, James lived briefly in Tokyo before returning to the UK to start at Red Gate.
What we’re working on
We launched a beta of our first tool, SSAS Compare, last month. It works like SQL Compare but for SSAS cubes, letting you deploy just the changes you want. It’s completely free (for now), so check it out. We’re still working on it, and we’re eager to hear what you think.
We hope SSAS Compare will be the first of several tools Red Gate develops for BI professionals, so keep an eye out for more from us in the future.
Why we need you
This is your chance to help influence the course of SSAS Compare and our future BI tools. If you’re a business intelligence specialist, we want to hear about the problems you face so we can build tools that solve them. What do you want to see? Tell us!
We’ll be posting more about SSAS Compare, business intelligence and our journey into BI in the coming days and weeks. Stay tuned!
Welcome to the first ever post on the brand new Red Gate Business Intelligence Tools Team blog!
About the team
Nick Sutherland (product manager): After many years as a software developer and project manager, Nick took an MBA and turned to product marketing. SSAS Compare is his second lean startup product (the first being SQL Connect). Follow him on Twitter.
David Pond (developer): Before he joined Red Gate in 2011, David made monitoring systems for Goodyear. Follow him on Twitter.
Jonathan Watts (tester): Jonathan became a tester after finishing his media degree and joining Xerox. He joined Red Gate in 2004. Follow him on Twitter.
James Duffy (technical author): After a spell as a writer in the video game industry, James lived briefly in Tokyo before returning to the UK to start at Red Gate.
What we're working on
We launched a beta of our first tool, SSAS Compare, last month. It works like SQL Compare but for SSAS cubes, letting you deploy just the changes you want. It's completely free (for now), so check it out. We're still working on it, and we're eager to hear what you think.
We hope SSAS Compare will be the first of several tools Red Gate develops for BI professionals, so keep an eye out for more from us in the future.
Why we need you
This is your chance to help influence the course of SSAS Compare and our future BI tools. If you're a business intelligence specialist, we want to hear about the problems you face so we can build tools that solve them. What do you want to see? Tell us!
We'll be posting more about SSAS Compare, business intelligence and our journey into BI in the coming days and weeks. Stay tuned!
I am installing SQL server 2008. I have installed .Net framewok 3.5.
Then I got folder SQL Server 2008.Then I performed following steps-
In that I clicked configuration Tools.
Then I clicked SQL Server Installation Center.
I clicked "Installation" hyperlink on left side.
Then I clicked "New SQL server stand-alone installation or add features to an existing installation"
Then i got a window "Browse for SQL server Installation Media"
which folder should i choose..?? OR is there any other method to install SQL Server..??
Hi,
I'm using pyodbc to talk to a legacy Access 2000 .mdb file.
I've got a cursor, and am trying to execute this:
c.execute("INSERT INTO [Accounts] ([Name], [TypeID], [StatusID], [AccountCat], [id]) VALUES (?, ?, ?, ?, ?)", [u'test', 20, 10, 4, 2])
However, doing so results in
pyodbc.Error: ('HYC00', '[HYC00] [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented (106) (SQLBindParameter)')
I understand I can simply change the question marks to the literal values, but in my experience proper escaping of strings across databases is... not pretty.
PHP and mysql team up to bring mysql_real_escape_string and friends, but I can't seem to find pyodbc's function for escaping values.
If you could let me know what the recommended way of inserting this data (from python) is, that'd be very helpful. Alternatively, if you have a python function to escape the odbc strings, that would also be great.
Thanks for the help.
I am currently investigating how to make a connection to a SQL Server database from my Java EE web application using Windows Authentication instead of SQL Server authentication. I am running this app off of Tomcat 6.0, and am utilizing the Microsoft JDBC driver. My connection properties file looks as follows:
dbDriver = com.microsoft.sqlserver.jdbc.SQLServerDriver
dbUser = user
dbPass = password
dbServer = localhost:1433;databaseName=testDb
dbUrl = jdbc:sqlserver://localhost:1433
I have zero problems with connecting to a SQL Server database in this fashion when using SQL Server authentication.
Is there any way I can retrieve the credentials of the user's Windows Authentication and use that authentication for SQL Server?
UPDATE: I know in ASP.net there is a way to set up Windows Authentication for access to the webapp, which is exactly what I am looking for, except I want to pass that token off to SQL Server for access to the database.
I have a report that has ~1k columns and ~17k rows and I'm trying to render it to Excel 2007 with SSRS 2008 R2 Nov CTP.
SSRS team members have mentioned in multiple places that Excel 2007 format is included in 2008 R2, for instance:
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/69545568-73cb-4f4c-8f35-44472ba6d013
Now, it's certainly possible that it just hasn't made it into the product yet (at least as of Nov CTP), and if that's the case, that would be good to know, too (and ideally when it would be in the product).
The repro report and data (along with attempts showing the existing interface still does Excel 2003 format) are attached to the bottom of this blog post, FWIW:
http://cid-456117cf53a42144.spaces.live.com/default.aspx
I am creating a status board module for my project team. The status board allows the user to to set their status as in or out and they can also provide a note. I was planning on storing all the information in a single table ... and example of the data follows:
Date User Status Notes
-------------------------------------------------------
1/8/2009 12:00pm B.Sisko In Out to lunch
1/8/2009 8:00am B.Sisko In
1/7/2009 5:00pm B.Sisko In
1/7/2009 8:00am B.Sisko In
1/7/2009 8:00am K.Janeway In
1/5/2009 8:00am K.Janeway In
1/1/2009 8:00am J.Picard Out Vacation
I would like to query the data and return the most recent status for each user, in this case, my query would return the following results:
Date User Status Notes
-------------------------------------------------------
1/8/2009 12:00pm B.Sisko In Out to lunch
1/7/2009 8:00am K.Janeway In
1/1/2009 8:00am J.Picard Out Vacation
I am try to figure out the TRANSACT-SQL to make this happen? Any help would be appreciated.
At the DreamForce 2010 event in San Francisco Force.com unveiled their next big thing in the Fat SaaS portfolio "Database.com". I am still wondering how would they would've shelled out for that domain name.
Now why would a already established SaaS player foray into a key building block like Database? Potentially allowing enterprises to build apps that do not utilize the Force.com stack! One key reason is being seen as the Fat SaaS player with evey trick in the SaaS space under his belt. You want CRM come hither, want a custom development PaaS like solution welcome home (VMForce), want all your apps to talk to a cloud DB and minimize latency by having it reside closer to you cloud apps? You've come to the right place sire! Other is potentially killing foray of smaller DB players like Oracle (Not surprisingly, the Database.com offering is a highly customized and scalable Oracle database) from entering the lucrative SaaS db marketplace.
The feature set promised looks great out of the box for someone who likes to visualize cool new architectures. The ground realities are certainly going to be a lot different considering the SOAP/REST style access patterns in lieu of the comfortable old shoe of SQL. Microsoft suffered heavily with SDS (SQL Data Services) offering in early 2009 and had to pull the plug on the product only to reintroduce as a simple SQL Server in the cloud, SQL Windows Azure. Though MSFT is playing cool by providing OData semantics to work with SQL Windows Azure satisfying atleast some needs of the Web-Style to a DB.
The other features like Social data models including Profiles, Status updates, feeds seem interesting as well. (Although I beleive social is just one of the aspects of large scale collaborative computing). All these features start "Free" for devs its a good news but the good news stops here. The overall pricing model of $ per Users per Transactions / Month is highly disproportionate compared to Amazon RDS (Based on MySQL) or SQL Windows Azure (Based on MSSQL). Roger Jennigs of Oakleaf did an interesting comparo based on 3, 10, 100, 500 users and it turns out that Database.com going by current understanding is way too expensive for the services on offer.
The offering may not impact the decision for DotNet shops mulling their cloud stategy or even some Java/MySQL shops thinking about Amazon RDS, however for enterprises having already invested in other force.com offerings this could be a very important piece in the cloud strategy jigsaw. One which would address a key cloud DB issue of "Latency" for them at least it will help having the DB in the neighborhood.
The tooling and "SQL like" access provider drivers (Think ODBC/JDBC) will be available later this year. Progress Software has already announced their JDBC driver stack for Database.com. It remains to be seen how effective the overall solutions proves to be in the longer run but for starts its a important decision towards consolidating Force.com's already strong positioning in the SaaS space.
As always contrasting views are welcome! :)
The only thing more controversial than new Federal Tax plans is new Licensing plans from Microsoft. In both cases, everyone calculates several numbers.
First, will I pay more or less under this plan?
Second, will my competition pay more or less than now?
Third, will <insert interesting person/company here> pay more or less?
Not that items 2 and 3 are meaningful, that is just how people think.
Much like tax plans, the devil is in the details, so lets see how this looks. Microsoft shows it here: http://www.microsoft.com/sqlserver/en/us/future-editions/sql2012-licensing.aspx
First up is a switch from per-socket to per-core licensing. Anyone who didn’t see something like this coming should rapidly search for a new line of work because you are not paying attention. The explosion of multi-core processors has made SQL Server a bargain. Microsoft is in business to make money and the old per-socket model was not going to do that going forward.
Per-core licensing also simplifies virtualization licensing. Physical Core = Virtual Core, at least for licensing. Oversubscribe your processors, that’s your lookout. You still pay for what is exposed to the VM. The cool part is you can seamlessly move physical and virtual workloads around and the licenses follow. The catch is you have to have Software Assurance to make the licenses mobile. Nice touch there.
Let’s have a moment of silence for the late, unlamented, largely ignored Workgroup Edition. To quote the Microsoft FAQ: “Standard becomes our sole edition for basic database needs”. Considering I haven’t encountered a singe instance of SQL Server Workgroup Edition in the wild, I don’t think this will be all that controversial.
As for pricing, it looks like a wash with current per-socket pricing based on four core sockets. Interestingly, that is the minimum core count Microsoft proposes to swap to transition per-socket to per-core if you are on Software Assurance. Reading the fine print shows that if you are using more, you will get more core licenses:
From the licensing FAQ.
15. How do I migrate from processor licenses to core licenses? What is the migration path?
Licenses purchased with Software Assurance (SA) will upgrade to SQL Server 2012 at no additional cost. EA/EAP customers can continue buying processor licenses until your next renewal after June 30, 2012. At that time, processor licenses will be exchanged for core-based licenses sufficient to cover the cores in use by processor-licensed databases (minimum of 4 cores per processor for Standard and Enterprise, and minimum of 8 EE cores per processor for Datacenter).
Looks like the folks who invested in the AMD 12-core chips will make out like bandits.
Now, on to something new: SQL Server Business Intelligence Edition. Yep, finally a BI-specific SKU licensed for server+CAL configurations only. Note that Enterprise Edition still supports the complete feature set; the BI Edition is intended for smaller shops who want to use the full BI feature set but without needing Enterprise Edition scale (or costs). No, you don’t get ColumnStore, Compression, or Partitioning in the BI Edition. Those are Enterprise scale features, ThankYouVeryMuch. Then again, your starting licensing costs are about one sixth of an Enterprise Edition system (based on an 8 core server).
The only part of the message I am missing is if the current Failover Licensing Policy will change. Do we need to fully or partially license failover servers? That is a detail I definitely want to know.
I have a table with transactions. Each transaction has a transaction ID, and accounting period (AP), and a posting value (PV), as well as other fields. Some of the IDs are duplicated, usually because the transaction was done in error. To give an example, part of the table might look like:
ID PV AP
123 100 2
123 -100 5
In this case the transaction was added in AP2 then removed in AP5.
Another example would be:
ID PV AP
456 100 2
456 -100 5
456 100 8
In the first example, the problem is that if I am analyzing what was spent in AP2, there is a transaction in there which actually shouldn't be taken into account because it was taken out again in AP5. In the second example, the second two transactions shouldn't be taken into account because they cancel each other out.
I want to label as many transactions as possible which shouldn't be taken into account as erroneous. To identify these transactions, I want to find the ones with duplicate IDs whose PVs sum to zero (like ID 123 above) or transactions where the PV of the earliest one is equal to sum(PV), as in the second example. This second condition is what is causing me grief.
So far I have
SELECT *
FROM table
WHERE table.ID IN (SELECT table.ID
FROM table
GROUP BY table.ID
HAVING COUNT(*) > 1
AND (SUM(table.PV) = 0
OR SUM(table.PV) = <PV of first transaction in each group>))
ORDER BY table.ID;
The bit in chevrons is what I'm trying to do and I'm stuck. Can I do it like this or is there some other method I can use in SQL to do this?
Edit 1: Btw I forgot to say that I'm using SQL Compact 3.5, in case it matters.
Edit 2: I think the code snippet above is a bit misleading. I still want to mark out transactions with duplicate IDs where sum(PV) = 0, as in the first example. But where the PV of the earliest transaction = sum(PV), as in the second example, what I actually want is to keep the earliest transaction and mark out all the others with the same ID. Sorry if that caused confusion.
Edit 3: I've been playing with Clodoaldo's solution and have made some progress, but still can't get quite what I want. I'm trying to get the transactions I know for certain to be erroneous. Suppose the following transactions are also in the table:
ID PV AP
789 100 2
789 200 5
789 -100 8
In this example sum(PV) < 0 and the earliest PV < sum(PV) so I don't want to mark any of these out.
If I modify Clodoaldo's query as follows:
select t.*
from
t
left join (
select id, min(ap) as ap, sum(pv) as sum_pv
from t
group by id
having sum(pv) <> 0
) s on t.id = s.id and t.ap = s.ap and t.pv = s.sum_pv
where s.id is null
This gives the result
ID PV AP
123 100 2
123 -100 5
456 -100 5
456 100 8
789 100 3
789 200 5
789 -100 8
Whilst the first 4 transactions are ok (they would be marked out), the 789 transactions are also there, and I don't want them. But I can't figure out how to modify the query so that they're not included. Any ideas?