Search Results

Search found 37012 results on 1481 pages for 'sql query'.

Page 76/1481 | < Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >

  • 24 hours of PASS is back!

    - by Sergio Govoni
    The most important free on-line event on SQL Server and Business Intelligence is back! The 24 Hours of PASS is coming back with a great edition fully based on the new features of SQL Server 2014. What could you aspect from the next PASS Summit? Find it out on June 25, 2014 (12:00 GMT) on 24 Hours of PASS: SQL Server 2014! Register now at this link. No matter from what part of the world you will follow the event, the important thing is to know that it will be 24 hours of continuous training on SQL Server and Business Intelligence.

    Read the article

  • The most dangerous SQL Script in the world!

    - by DrJohn
    In my last blog entry, I outlined how to automate SQL Server database builds from concatenated SQL Scripts. However, I did not mention how I ensure the database is clean before I rebuild it. Clearly a simple DROP/CREATE DATABASE command would suffice; but you may not have permission to execute such commands, especially in a corporate environment controlled by a centralised DBA team. However, you should at least have database owner permissions on the development database so you can actually do your job! Then you can employ my universal "drop all" script which will clear down your database before you run your SQL Scripts to rebuild all the database objects. Why start with a clean database? During the development process, it is all too easy to leave old objects hanging around in the database which can have unforeseen consequences. For example, when you rename a table you may forget to delete the old table and change all the related views to use the new table. Clearly this will mean an end-user querying the views will get the wrong data and your reputation will take a nose dive as a result! Starting with a clean, empty database and then building all your database objects using SQL Scripts using the technique outlined in my previous blog means you know exactly what you have in your database. The database can then be repopulated using SSIS and bingo; you have a data mart "to go". My universal "drop all" SQL Script To ensure you start with a clean database run my universal "drop all" script which you can download from here: 100_drop_all.zip By using the database catalog views, the script finds and drops all of the following database objects: Foreign key relationships Stored procedures Triggers Database triggers Views Tables Functions Partition schemes Partition functions XML Schema Collections Schemas Types Service broker services Service broker queues Service broker contracts Service broker message types SQLCLR assemblies There are two optional sections to the script: drop users and drop roles. You may use these at your peril, particularly as you may well remove your own permissions! Note that the script has a verbose mode which displays the SQL commands it is executing. This can be switched on by setting @debug=1. Running this script against one of the system databases is certainly not recommended! So I advise you to keep a USE database statement at the top of the file. Good luck and be careful!!

    Read the article

  • Last chance for a day of free SQL Server training at SQL in the City 2012

    SQL Server developers and database administrators have one last chance for a full day of free training and networking at SQL in the City 2012. NEW! Deployment Manager Early Access ReleaseDeploy SQL Server changes and .NET applications fast, frequently, and without fuss, using Deployment Manager, the new tool from Red Gate. Try the Early Access Release to get a 20% discount on Version 1. Download the Early Access Release.

    Read the article

  • SQL Date Comparison

    - by Derek Dieter
    When comparing the datetime datatype in SQL Server, it is important to maintain consistency in order to gaurd against SQL interpreting a date differently than you intend. In at least one occasion I have seen someone specify a short format for a date, like (1/4/08) only to find that SQL interpreted the month as [...]

    Read the article

  • Creating a SQL Azure Database Should be Easier

    - by Ken Cox [MVP]
    Every time I try to create a database + tables + data for Windows Azure SQL I get errors.  One of them is 'Filegroup reference and partitioning scheme' is not supported in this version of SQL Server.' It’s partly due to my poor memory (since I’ve succeeded before) and partly due to the failure of tools that should be helping me. For example, when I want to create a script from an existing database on my local workstation, I use SQL Server Management Studio (currently v 11.0.2100.60).  I go to Tasks > Generate Scripts which brings up the nice Generate and Publish Scripts wizard. When I go into the Advanced button, under Script for Server Version, why don’t I see SQL Azure as an option by now? The tool should be sorting this out for me, right? Maybe this is available in SQL Server Data Tools? I haven’t got into that yet. Just merge the functionality with SSMS, please. Anyway, I pick an older version of SQL for the target and still need to tweak it for Azure. For example, I take out all the “[dbo].” stuff. Why is it put there by the wizard? I also have to get rid of "ON [PRIMARY]"  to deal with the error I noted at the top. Yes, there’s information on what a table needs to look like in SQL Azure but the tools should know this so I don’t have to mess with it.

    Read the article

  • Simple way to create a SQL Server Job Using T-SQL

    Sometimes we have a T-SQL process that we need to run that takes some time to run or we want to run it during idle time on the server. We could create a SQL Agent job manually, but is there any simple way to create a scheduled job? The seven tools in the SQL DBA Bundle support your core SQL Server database administration tasks.Make backups a breeze! Enjoy trouble-free troubleshooting! Make the most of monitoring! Download a free trial now.

    Read the article

  • Stairway to SQL PowerShell Level 4: Objects in SQL PowerShell

    This far, we have learned about installation and setup of the PowerShell environment. You should now have a foundation of SQL Server PowerShell. We now are ready to learn about Objects in SQL PowerShell. Schedule Azure backupsRed Gate’s Cloud Services makes it simple to create and schedule backups of your SQL Azure databases to Azure blob storage or Amazon S3. Try it for free today.

    Read the article

  • T-SQL Tuesday #34: HELP!

    - by merrillaldrich
    I owe my career to the SQL Server community, specifically the Internet SQL Server community, so this month’s T-SQL Tuesday is especially poignant. I changed careers “cold” about eight years ago, and, while I had some educational background in computer science, I had relatively little real-world DBA experience. Someone gave me a shot in the form of an entry level job, for which I am grateful, but I also had to make the argument to him that I would figure out whatever I needed to do to be successful...(read more)

    Read the article

  • Query only the first detail record for each master record

    - by Neal S.
    If I have the following master-detail relationship: owner_tbl auto_tbl --------- -------- owner --- owner auto year And I have the following table data: owner_tbl auto_tbl --------- -------- john john, corvette, 1968 john, prius, 2008 james james, f-150, 2004 james, cadillac, 2002 james, accord, 2009 jeff jeff, tesla, 2010 jeff, hyundai, 1996 Now, I want to perform a query that returns the following result: john, corvette, 1968 jeff, hyundai, 1996 james, cadillac, 2002 The query should join the two tables, and sort all the records on the "year" field, but only return the first detail record for each master record. I know how to join the tables and sort on the "year" field, but it's not clear how (or if) I might be able to only retrieve the first joined record for each owner. Three related questions: Can I perform this kind of query using LINQ-to-SQL? Can I perform the query using T-SQL? Would it be best to just create a stored procedure for the query given its likely complexity?

    Read the article

  • sql-server: Can I update two table with Single Query?

    - by RedsDevils
    How can I write single UPDATE query to change value of COL1 to ‘X’ if COL2 < 10 otherwise change it to ‘Y’, where the following two tables are linked by ID CREATE TABLE TEMP(ID TINYINT, COL1 CHAR(1)) INSERT INTO TEMP(ID,COL1) VALUES (1,'A') INSERT INTO TEMP(ID,COL1) VALUES (2,'B') INSERT INTO TEMP(ID,COL1) VALUES (11,'A') INSERT INTO TEMP(ID,COL1) VALUES (17,'B') CREATE TABLE TEMP2(ID TINYINT, COL2 TINYINT) INSERT INTO TEMP2(ID,COL2) VALUES (1,1) INSERT INTO TEMP2(ID,COL2) VALUES (2,5) INSERT INTO TEMP2(ID,COL2) VALUES (11,10) INSERT INTO TEMP2(ID,COL2) VALUES (17,15) Thanks in advance!

    Read the article

  • Query takes time on comparing non numeric data of two tables, how to optimize it?

    - by Muhammad Kashif Nadeem
    I have two DBs. The 1st db has CallsRecords table and 2nd db has Contacts table, both are on SQL Server 2005. Below is the sample of two tables. Contact table has 1,50,000 records CallsRecords has 75,000 records Indexes on CallsRecords: CallFrom CallTo PickUP Indexes on Contacts: PhoneNumber I am using this query to find matches but it take more than 7 minutes. SELECT * FROM CallsRecords r INNER JOIN Contact c ON r.CallFrom = c.PhoneNumber OR r.CallTo = c.PhoneNumber OR r.PickUp = c.PhoneNumber In Estimated execution plan inner join cost 95% Any help to optimize it.

    Read the article

  • I'm looking for a reliable way to verify T-SQL stored procedures. Anybody got one?

    - by Cory Larson
    Hi all-- We're upgrading from SQL Server 2005 to 2008. Almost every database in the 2005 instance is set to 2000 compatibility mode, but we're jumping to 2008. Our testing is complete, but what we've learned is that we need to get faster at it. I've discovered some stored procedures that either SELECT data from missing tables or try to ORDER BY columns that don't exist. Wrapping the SQL to create the procedures in SET PARSEONLY ON and trapping errors in a try/catch only catches the invalid columns in the ORDER BYs. It does not find the error with the procedure selecting data from the missing table. SSMS 2008's intellisense, however, DOES find the issue, but I can still go ahead and successfully run the ALTER script for the procedure without it complaining. So, why can I even get away with creating a procedure that fails when it runs? Are there any tools out there that can do better than what I've tried? The first tool I found wasn't very useful: DbValidator from CodeProject, but it finds fewer problems than this script I found on SqlServerCentral, which found the invalid column references. ------------------------------------------------------------------------- -- Check Syntax of Database Objects -- Copyrighted work. Free to use as a tool to check your own code or in -- any software not sold. All other uses require written permission. ------------------------------------------------------------------------- -- Turn on ParseOnly so that we don't actually execute anything. SET PARSEONLY ON GO -- Create a table to iterate through declare @ObjectList table (ID_NUM int NOT NULL IDENTITY (1, 1), OBJ_NAME varchar(255), OBJ_TYPE char(2)) -- Get a list of most of the scriptable objects in the DB. insert into @ObjectList (OBJ_NAME, OBJ_TYPE) SELECT name, type FROM sysobjects WHERE type in ('P', 'FN', 'IF', 'TF', 'TR', 'V') order by type, name -- Var to hold the SQL that we will be syntax checking declare @SQLToCheckSyntaxFor varchar(max) -- Var to hold the name of the object we are currently checking declare @ObjectName varchar(255) -- Var to hold the type of the object we are currently checking declare @ObjectType char(2) -- Var to indicate our current location in iterating through the list of objects declare @IDNum int -- Var to indicate the max number of objects we need to iterate through declare @MaxIDNum int -- Set the inital value and max value select @IDNum = Min(ID_NUM), @MaxIDNum = Max(ID_NUM) from @ObjectList -- Begin iteration while @IDNum <= @MaxIDNum begin -- Load per iteration values here select @ObjectName = OBJ_NAME, @ObjectType = OBJ_TYPE from @ObjectList where ID_NUM = @IDNum -- Get the text of the db Object (ie create script for the sproc) SELECT @SQLToCheckSyntaxFor = OBJECT_DEFINITION(OBJECT_ID(@ObjectName, @ObjectType)) begin try -- Run the create script (remember that PARSEONLY has been turned on) EXECUTE(@SQLToCheckSyntaxFor) end try begin catch -- See if the object name is the same in the script and the catalog (kind of a special error) if (ERROR_PROCEDURE() <> @ObjectName) begin print 'Error in ' + @ObjectName print ' The Name in the script is ' + ERROR_PROCEDURE()+ '. (They don''t match)' end -- If the error is just that this already exists then we don't want to report that. else if (ERROR_MESSAGE() <> 'There is already an object named ''' + ERROR_PROCEDURE() + ''' in the database.') begin -- Report the error that we got. print 'Error in ' + ERROR_PROCEDURE() print ' ERROR TEXT: ' + ERROR_MESSAGE() end end catch -- Setup to iterate to the next item in the table select @IDNum = case when Min(ID_NUM) is NULL then @IDNum + 1 else Min(ID_NUM) end from @ObjectList where ID_NUM > @IDNum end -- Turn the ParseOnly back off. SET PARSEONLY OFF GO Any suggestions?

    Read the article

  • Replication with SQL Server 2005 Express Edition and SQL Compact Edition 3.5

    - by Andy Gable
    hi all, I need some information on SQL Server 2005 Express edition. What I want to do is have my central database servin local machine databases IE back office Cental database |------------------- Shop floor Terminal 1 |------------------- Shop Floor Terminal 2 |------------------- Shop Floor Terminal 3 |------------------- Shop Floor Terminal 4 |------------------- Shop Floor Terminal 5 |------------------- Shop Floor Terminal 6 I want is so that Shop floor terminals would PULL down ANY changes to the database as and when they happen (selected changes are needed change would be Add new item / Edit Item info that is used by Shop floor terminal (ie price, description, sale group) Is this possible with SQL 2005? I have the ability to make my own Sync Applciation but I would need to know what to look for in the database that trigers a update Many thanks for any advice you can give Andy

    Read the article

  • SQL Server 2008 Express - "Best" backup solution?

    - by Alexander Nyquist
    Hi! What backup solutions would you recommend when using SQL Server 2008 express? I'm pretty new to SQL Server, but as I'm coming from an MySql background i thought of setting up replication on another computer and just take x-copy backups of that server. But unfortanetly replication is not available in the express edition. The site is heavily accessed, so there has to be no delays och downtime. I'm also thinking of doing a backup twice a day or something. What would you recommend? I have multiple computers I can use, but don't know if that helps me since i'm using the express version. Thanks

    Read the article

  • SQL Server 2005 jobs running twice in a row - using LiteSpeed

    - by Malnizzle
    Howdy! I have a SQL server (2005) backing up to a network share, who has a group of maintenance plans setup through LiteSpeed to backup different DBs. They were just set up to run two sub plans on different schedules for full/diff backups and did that just fine for a couple of months. Then I added "Clean Up" task to the subplans. Ever since that point, the backup creates another bak right after the first bak job is completed. I removed the clean up item from the subplan, and it still creates two baks when ran. Both the SQL Activity Monitor and the machine's windows application log show just one job being executed. I did this same thing to a couple of other servers backing up to the same location, and they are behaving correctly. Thoughts?

    Read the article

  • Tricky SQL query involving consecutive values

    - by Gabriel
    I need to perform a relatively easy to explain but (given my somewhat limited skills) hard to write SQL query. Assume we have a table similar to this one: exam_no | name | surname | result | date ---------+------+---------+--------+------------ 1 | John | Doe | PASS | 2012-01-01 1 | Ryan | Smith | FAIL | 2012-01-02 <-- 1 | Ann | Evans | PASS | 2012-01-03 1 | Mary | Lee | FAIL | 2012-01-04 ... | ... | ... | ... | ... 2 | John | Doe | FAIL | 2012-02-01 <-- 2 | Ryan | Smith | FAIL | 2012-02-02 2 | Ann | Evans | FAIL | 2012-02-03 2 | Mary | Lee | PASS | 2012-02-04 ... | ... | ... | ... | ... 3 | John | Doe | FAIL | 2012-03-01 3 | Ryan | Smith | FAIL | 2012-03-02 3 | Ann | Evans | PASS | 2012-03-03 3 | Mary | Lee | FAIL | 2012-03-04 <-- Note that exam_no and date aren't necessarily related as one might expect from the kind of example I chose. Now, the query that I need to do is as follows: From the latest exam (exam_no = 3) find all the students that have failed (John Doe, Ryan Smith and Mary Lee). For each of these students find the date of the first of the batch of consecutively failing exams. Another way to put it would be: for each of these students find the date of the first failing exam that comes after their last passing exam. (Look at the arrows in the table). The resulting table should be something like this: name | surname | date_since_failing ------+---------+-------------------- John | Doe | 2012-02-01 Ryan | Smith | 2012-01-02 Mary | Lee | 2012-01-04 Ann | Evans | 2012-02-03 How can I perform such a query? Thank you for your time.

    Read the article

  • Migrated SQL Server database suddenly in "Restoring" state

    - by Pete Montgomery
    Edit: This is still a live prob, less than an hour after trying RESTORE ... WITH RECOVERY. I backed up a SQL Server 2005 database and restored it to a new SQL 2008 instance. The restore was quick and successful. Everything was fine for an hour or so. Suddenly, the database is now stuck in "(Restoring...)" state in Management Studio and has a green arrow icon, and my application login is failing! Any advice? :-) Edit: This is a live application. If I delete and try again, the hour or so's data will be lost.

    Read the article

  • SQL CLR not properly enabling

    - by dnolan
    We have a SQL server running SQL 2005 Workgroup 64 bit (9.0.4273), on Windows 2003 server 64 bit. We have run sp_configure and reconfigured the server which indicates that the clr is now enabled. exec sp_configure 'clr enabled', '1' go reconfigure go However, when trying to call CREATE ASSEMBLY the server completely dies on us and we have to do a full reboot of the machine. A little more diagnostic information, even though clr enabled is set to 1 and we have rebooted the full server, running the following statement select * from sys.dm_clr_properties returns directory version state locked CLR version with mscoree which is what it says when the CLR is not enabled on another machine. On a correctly enabled machine (after reboot) this function reads directory C:\Windows\Microsoft.NET\Framework64\v2.0.50727\ version v2.0.50727 state CLR is initialized

    Read the article

  • Creating a dynamic linq query

    - by Bas
    I have the following query: from p in dataContext.Repository<IPerson>() join spp1 in dataContext.Repository<ISportsPerPerson>() on p.Id equals spp1.PersonId join s1 in dataContext.Repository<ISports>() on spp1.SportsId equals s1.Id join spp2 in dataContext.Repository<ISportsPerPerson>() on p.Id equals spp2.PersonId join s2 in dataContext.Repository<ISports>() on spp2.SportsId equals s2.Id where s1.Name == "Soccer" && s2.Name == "Tennis" select new { p.Id }; It selects all the person who play Soccer and Tennis. On runtime the user can select other tags to add to the query, for instance: "Hockey". now my question is, how could I dynamically add "Hockey" to the query? If "Hockey" is added to the query, it would look like this: from p in dataContext.Repository<IPerson>() join spp1 in dataContext.Repository<ISportsPerPerson>() on p.Id equals spp1.PersonId join s1 in dataContext.Repository<ISports>() on spp1.SportsId equals s1.Id join spp2 in dataContext.Repository<ISportsPerPerson>() on p.Id equals spp2.PersonId join s2 in dataContext.Repository<ISports>() on spp2.SportsId equals s2.Id join spp3 in dataContext.Repository<ISportsPerPerson>() on p.Id equals spp3.PersonId join s3 in dataContext.Repository<ISports>() on spp3.SportsId equals s3.Id where s1.Name == "Soccer" && s2.Name == "Tennis" && s3.Name == "Hockey" select new { p.Id }; It would be preferable if the query is build up dynamically like: private void queryTagBuilder(List<string> tags) { IDataContext dataContext = new LinqToSqlContext(new L2S.DataContext()); foreach(string tag in tags) { //Build the query? } } Anyone has an idea on how to set this up correctly? Thanks in advance!

    Read the article

  • SQL Server Snapshot Replication Subscriber (Editable or Read-Only)

    - by NateReid
    I need to create a copy of my SQL 2008 R2 Enterprise database and have it located on the same server as the original. I will be using this second copy of the database as the target of a mostly read-only website. I understand that if I create this copy of the database using snapshot replication that all data changes in the subscriber database will be overwriten in the event of the next replication. The web application will try to write to this database to record login attempts, etc and will fail if its source database is read-only. In my case I do not need to keep these auditing records and they can therefore be overwriten each time a new snapshot is applied. My question is whether SQL Server forces the subcriber database to be read-only and is there any way around this? Thank you, Nate

    Read the article

  • SQL Server Windows Auth Login not working

    - by Mr Shoubs
    I've had someone set up a domain controller on windows 2008 on one server, and sql server 2008 on another. The domain seems to be working fine, I'm logged on as a domain user on both servers, nothing seems to be a problem there. However, when I try to add a domain user/group to SQL Server Security (e.g. clicking ok from the create login screen) it says it can't find it (even though I've used the search to find the correct account in the first place), when I try to logon (even though I haven't added it yet) it says something about the account being part of an untrusted domain instead of saying I don't have permission to log on. Anyone have any ideas on what is set up incorrectly?

    Read the article

  • Stop SQL Server services from conveniently

    - by MedicineMan
    I have a general use laptop. I use it for games, development, and web surfing. I've just installed SQL Server 2008 with Analysis, Reporting, and Error reporting, as well as any of the other options on the installer. I also have a default instance of SQL server as well as a named instance. When I'm not doing development, I'd like to shut down these services conveniently. I'm thinking that a batch file would be good. What are the commands to shut these services down and release the associated memory and resources? It appears that: net stop MSSQLSERVER seems to stop the MSSQLSERVER instance. What about the other services?

    Read the article

  • SQL Server 2008 Express - "Best" backup solution?

    - by alexn
    What backup solutions would you recommend when using SQL Server 2008 Express? I'm pretty new to SQL Server, but as I'm coming from an MySQL background I thought of setting up replication on another computer and just take Xcopy backups of that server. But unfortunately replication is not available in the Express Edition. The site is heavily accessed, so there has to be no delays and downtime. I'm also thinking of doing a backup twice a day or something. What would you recommend? I have multiple computers I can use, but I don't know if that helps me since I'm using the Express version.

    Read the article

< Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >