Search Results

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

Page 113/1481 | < Previous Page | 109 110 111 112 113 114 115 116 117 118 119 120  | Next Page >

  • Dynamically assembling SQL queries in Java

    - by kd
    What is the best way to assemble an SQL query with join conditions dynamically? I don't want to hard code the query for each different condition on a webpage or a set of webpages. Is it even feasible? I got as far as being able to assemble simple queries but i got stumped when i needed to insert join conditions, i.e. how to figure out dependencies for joins etc.

    Read the article

  • MS SQL tuning tools for finding overload

    - by SkyFox
    I use MS SQL server as a DBMS for my very big corporate DB (with different financial data). And some times my system go down. I don't understand why. What programs/tools I can use for finding process/program/thread, that overload my SQL-server? Thanks for all answers!

    Read the article

  • Should a data warehouse developer know Powershell scripting?

    - by AEngelsrud
    I am a SQL Server (2005 & 2008) data warehouse developer (SSIS, SSAS, SSRS, SQL) and I am wondering if it would be worth the effort and time to learn Powershell scripting. Are there applicable uses from a development perspective? I understand that from a DBA view there is considerable power in Powershell for administration - does any of this translate to useful commands for a developer? Thanks!

    Read the article

  • How to create a "copy" of SQL Server transaction log file

    - by Salman A
    I want a copy of SQL Server transaction log file for "raw" analysis. What is the safest way to get a copy of that file without shutting down the database and disturbing the existing log/backups/backup schedules and just about everything. FYI, Its a SQL Server 2000 database server and I can see the log file (its about 4GB in size) and I cannot copy it as is; I get the "access denied" error when copying from explorer or command line.

    Read the article

  • Best index(es) to use for an OR Statement in SQL Server

    - by Chuck Haines
    I have a table which has a bunch of columns but the two relevant ones are: Due_Amount MONEY Bounced_Due_Amount MONEY I have a SQL query like the following SELECT * FROM table WHERE (Due_Amount 0 OR Bounced_Due_Amount 0) Would the best index to put on this table for SQL Server 2008 be an index which includes both columns in the index, or should I put an separate index on each column?

    Read the article

  • Parameterizing a SQL IN clause?

    - by Jeff Atwood
    How do I parameterize a query containing an IN clause with a variable number of arguments, like this one? select * from Tags where Name in ('ruby','rails','scruffy','rubyonrails') order by Count desc In this query, the number of arguments could be anywhere from 1 to 5. I would prefer not to use a dedicated stored procedure for this (or XML), but if there is some fancy SQL Server 2008 specific way of doing it elegantly, I am open to that.

    Read the article

  • New help with SQL Server select statement

    - by gio_333m
    I need help with select statement in SQL Server / T-SQL My table looks like this: Id (int) QuestionId (int) GenreId (int) I want to select random N rows from this table so that maximum number of same GenreId in the result set is less than X for all GenreId-s except one. For that one GenreId, I need row count with that GenreId to be equal to Y.

    Read the article

  • SQL to delete duplicate records in a table [closed]

    - by oo
    Possible Duplicate: Delete duplicate records from a SQL table without a primary key I have a table with the columns person_ID firstname lastname and I somehow ended up with a bunch of duplicates. Is there any way to look at all columns where firstname and lastname are the same and delete all except one of them (it doesn't matter which one is left as they are all the same.) EDIT: I just found a duplicate question and perfect answer: http://stackoverflow.com/questions/985384/delete-duplicate-records-from-a-sql-table-without-a-primary-key

    Read the article

  • Network communications mechanisms for SQL Server

    - by Akshay Deep Lamba
    Problem I am trying to understand how SQL Server communicates on the network, because I'm having to tell my networking team what ports to open up on the firewall for an edge web server to communicate back to the SQL Server on the inside. What do I need to know? Solution In order to understand what needs to be opened where, let's first talk briefly about the two main protocols that are in common use today: TCP - Transmission Control Protocol UDP - User Datagram Protocol Both are part of the TCP/IP suite of protocols. We'll start with TCP. TCP TCP is the main protocol by which clients communicate with SQL Server. Actually, it is more correct to say that clients and SQL Server use Tabular Data Stream (TDS), but TDS actually sits on top of TCP and when we're talking about Windows and firewalls and other networking devices, that's the protocol that rules and controls are built around. So we'll just speak in terms of TCP. TCP is a connection-oriented protocol. What that means is that the two systems negotiate the connection and both agree to it. Think of it like a phone call. While one person initiates the phone call, the other person has to agree to take it and both people can end the phone call at any time. TCP is the same way. Both systems have to agree to the communications, but either side can end it at any time. In addition, there is functionality built into TCP to ensure that all communications can be disassembled and reassembled as necessary so it can pass over various network devices and be put together again properly in the right order. It also has mechanisms to handle and retransmit lost communications. Because of this functionality, TCP is the protocol used by many different network applications. The way the applications all can share is through the use of ports. When a service, like SQL Server, comes up on a system, it must listen on a port. For a default SQL Server instance, the default port is 1433. Clients connect to the port via the TCP protocol, the connection is negotiated and agreed to, and then the two sides can transfer information as needed until either side decides to end the communication. In actuality, both sides will have a port to use for the communications, but since the client's port is typically determined semi-randomly, when we're talking about firewalls and the like, typically we're interested in the port the server or service is using. UDP UDP, unlike TCP, is not connection oriented. A "client" can send a UDP communications to anyone it wants. There's nothing in place to negotiate a communications connection, there's nothing in the protocol itself to coordinate order of communications or anything like that. If that's needed, it's got to be handled by the application or by a protocol built on top of UDP being used by the application. If you think of TCP as a phone call, think of UDP as a postcard. I can put a postcard in the mail to anyone I want, and so long as it is addressed properly and has a stamp on it, the postal service will pick it up. Now, what happens it afterwards is not guaranteed. There's no mechanism for retransmission of lost communications. It's great for short communications that doesn't necessarily need an acknowledgement. Because multiple network applications could be communicating via UDP, it uses ports, just like TCP. The SQL Browser or the SQL Server Listener Service uses UDP. Network Communications - Talking to SQL Server When an instance of SQL Server is set up, what TCP port it listens on depends. A default instance will be set up to listen on port 1433. A named instance will be set to a random port chosen during installation. In addition, a named instance will be configured to allow it to change that port dynamically. What this means is that when a named instance starts up, if it finds something already using the port it normally uses, it'll pick a new port. If you have a named instance, and you have connections coming across a firewall, you're going to want to use SQL Server Configuration Manager to set a static port. This will allow the networking and security folks to configure their devices for maximum protection. While you can change the network port for a default instance of SQL Server, most people don't. Network Communications - Finding a SQL Server When just the name is specified for a client to connect to SQL Server, for instance, MySQLServer, this is an attempt to connect to the default instance. In this case the client will automatically attempt to communicate to port 1433 on MySQLServer. If you've switched the port for the default instance, you'll need to tell the client the proper port, usually by specifying the following syntax in the connection string: <server>,<port>. For instance, if you moved SQL Server to listen on 14330, you'd use MySQLServer,14330 instead of just MySQLServer. However, because a named instance sets up its port dynamically by default, the client never knows at the outset what the port is it should talk to. That's what the SQL Browser or the SQL Server Listener Service (SQL Server 2000) is for. In this case, the client sends a communication via the UDP protocol to port 1434. It asks, "Where is the named instance?" So if I was running a named instance called SQL2008R2, it would be asking the SQL Browser, "Hey, how do I talk to MySQLServer\SQL2008R2?" The SQL Browser would then send back a communications from UDP port 1434 back to the client telling the client how to talk to the named instance. Of course, you can skip all of this of you set that named instance's port statically. Then you can use the <server>,<port> mechanism to connect and the client won't try to talk to the SQL Browser service. It'll simply try to make the connection. So, for instance, is the SQL2008R2 instance was listening on port 20080, specifying MySQLServer,20080 would attempt a connection to the named instance. Network Communications - Named Pipes Named pipes is an older network library communications mechanism and it's generally not used any longer. It shouldn't be used across a firewall. However, if for some reason you need to connect to SQL Server with it, this protocol also sits on top of TCP. Named Pipes is actually used by the operating system and it has its own mechanism within the protocol to determine where to route communications. As far as network communications is concerned, it listens on TCP port 445. This is true whether we're talking about a default or named instance of SQL Server. The Summary Table To put all this together, here is what you need to know: Type of Communication Protocol Used Default Port Finding a SQL Server or SQL Server Named Instance UDP 1434 Communicating with a default instance of SQL Server TCP 1433 Communicating with a named instance of SQL Server TCP * Determined dynamically at start up Communicating with SQL Server via Named Pipes TCP 445

    Read the article

  • Row concat from this query

    - by Álvaro G. Vicario
    I have this query: SELECT DISTINCT IM.EDIFICIOS_ID, TI.TITULAR FROM IMPORTACION IM INNER JOIN I_EDIFICIO IE ON IM.IMPORTACION_ID=IE.IMPORTACION_ID INNER JOIN I_EDIFICIO_TITULAR ET ON IM.IMPORTACION_ID=ET.IMPORTACION_ID AND IE.EDIFICIO_ID=ET.EDIFICIO_ID INNER JOIN I_TITULAR TI ON IM.IMPORTACION_ID=TI.IMPORTACION_ID AND ET.TITULAR_ID=TI.TITULAR_ID WHERE TI.TITULAR IS NOT NULL AND TI.TITULAR<>'' ORDER BY IM.EDIFICIOS_ID, TI.TITULAR; that returns this result set: EDIFICIOS_ID TITULAR ------------ ------------------ 1911 Ana María García 1911 Anselmo Piedrahita 1911 Manuel López 2594 Carlos Pérez 2594 Felisa García 6865 Carlos Pérez 6865 Felisa García 8428 Carlos Pérez I want to concatenate the values from TITULAR for each EDIFICIOS_ID, so I get this: EDIFICIOS_ID TITULAR ------------ ------------------ 1911 Ana María García; Anselmo Piedrahita; Manuel López 2594 Carlos Pérez; Felisa García 6865 Carlos Pérez; Felisa García 8428 Carlos Pérez I'm trying to use the FOR XML PATH trick. I've used it in the past but, since I can't really understand how it works, I can't figure out how to apply it to this specific case. Can you provide me with some ideas?

    Read the article

  • SQL Server Gender Swap Query

    - by Sanju
    I have a Table having the following column: ID, Name, Designation, Salary, Contact, Address, Gender Accidentally for all male Gender i have entered 'Female' and similarly for all Female gender i have entered 'Male'. For Exmaple 0023 Scott Developer 15000 4569865 Cliff_Eddington,USA Female I the above line There should be Male instead of female. And there are all Male whose gender has been updated as Female. Same case for all Female Gender has been updated as Male. Is there any Single query through which i can change all the Rows whose Gender is Male Change it to Female and All the Rows whose Gender is Female Change it to Male.

    Read the article

  • Select query 2-3 times faster than view

    - by Richard Knop
    This query run alone: SELECT -- lots of columns FROM (((((((((((`table1` `t1` LEFT JOIN `table2` `t2` ON(( `t2`.`userid` = `t1`.`userid` ))) LEFT JOIN `table3` `t3` ON(( `t1`.`orderid` = `t3`.`orderid` ))) LEFT JOIN `table4` `t4` ON(( `t4`.`orderitemlicenseid` = `t3`.`orderitemlicenseid` ))) LEFT JOIN `table5` `t5` ON(( `t1`.`orderid` = `t5`.`orderid` ))) LEFT JOIN `table6` `t6` ON(( `t5`.`transactionid` = `t6`.`transactionid` ))) LEFT JOIN `table7` `t7` ON(( `t7`.`transactionid` = `t5`.`transactionid` ))) LEFT JOIN `table8` `t8` ON(( `t8`.`voucherid` = `t7`.`voucherid` ))) LEFT JOIN `table9` `t9` ON(( `t8`.`voucherid` = `t9`.`voucherid` ))) LEFT JOIN `table10` `t10` ON(( ( `t10`.`vouchergroupid` = `t9`.`vouchergroupid` ) AND ( `t2`.`territoryid` = `t10`.`territoryid` ) ))) LEFT JOIN `table11` `t11` ON(( `t11`.`voucherid` = `t8`.`voucherid` ))) LEFT JOIN `table12` `t12` ON(( `t12`.`orderid` = `t1`.`orderid` ))) GROUP BY `t5`.`transactionid` Takes about 2.5 seconds to finish. When I save it to a view and run it as: SELECT * FROM viewName; It takes 7 seconds to finish. What is the reason and how can I make the view faster?

    Read the article

  • Return SQL Query as Array in Powershell

    - by Emo
    I have a SQL 2008 Ent server with the databases "DBOne", "DBTwo", "DBThree" on the server DEVSQLSRV. Here is my Powershell script: $DBNameList = (Invoke-SQLCmd -query "select Name from sysdatabases" -Server DEVSQLSRV) This produces my desired list of database names as: Name ----- DBOne DBTwo DBThree I has been my assumption that anything that is returned as a list is an Array in Powershell. However, when I then try this in Powershell: $DBNameList -contains 'DBTwo' It comes back has "False" instead of "True" which is leading me to believe that my list is not an actual array. Any idea what I'm missing here? Thanks so much! Emo

    Read the article

  • T-SQL query to check number of existences

    - by abatishchev
    I have next approximate tables structure: accounts: ID INT, owner_id INT, currency_id TINYINT related to clients: ID INT and currency_types: ID TINYINT, name NVARCHAR(25) I need to write a stored procedure to check existence of accounts with specific currency and all others, i.e. client can have accounts in specific currency, some other currencies and both. I have already written this query: SELECT ISNULL(( SELECT 1 WHERE EXISTS ( SELECT 1 FROM [accounts] AS A, [currency_types] AS CT WHERE A.[owner_id] = @client -- sp param AND A.[currency_id] = CT.[ID] AND CT.[name] = N'Ruble' )), 0) AS [ruble], ISNULL(( SELECT 1 WHERE EXISTS ( SELECT A.[ID] FROM [accounts] AS A, [currency_types] AS CT WHERE A.[owner_id] = @client AND A.[currency_id] = CT.[ID] AND CT.[name] != N'Ruble' )), 0) AS [foreign] Is it possible to optimize it? I'm new to (T)SQL, so thanks in advance!

    Read the article

  • Please for efficient query

    - by user278618
    I want to have efficient query to get some rows from my table. Here is I think the best presentation of my table. -Somedate is not duplicated - it is date of modifiedon -a,b,c are parent ids, let say countryCode -1,2,3,4 are subparent, let say citycode -guids are id of rows -true, false are values of rows - one can name this column - freshAir a 1 GUID somedate true a 1 GUID somedate true a 2 GUID somedate false a 2 GUID somedate false b 3 GUID somedate false b 3 GUID somedate false b 3 GUID somedate false b 4 GUID somedate false c 5 GUID somedate true c 6 GUID somedate true c 6 GUID somedate false c 6 GUID somedate false c 7 GUID somedate false I want the most recent rows MAX(modifiedon) grouped by countrycode and citycode and in this groups I need elements which have another values (true, false). And in result I want: a 1 GUID somedate true a 2 GUID somedate false c 5 GUID somedate true c 6 GUID somedate false c 7 GUID somedate false Look that in result I don't want to have records with "b", because all rows have the same value (false). Best regards

    Read the article

  • How to export SQL Server 2005 query to CSV

    - by jmgant
    I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the fields (except concatenating them to the field values, which is ugly). I guess I could do it with sqlcmd and -o, but that seems ugly for the same reason. Is there a bcp way to do it? Is there a reasonable sqlcmd way to do it? Is there some great, simple utility built into the Management Studio that I'm just overlooking?

    Read the article

< Previous Page | 109 110 111 112 113 114 115 116 117 118 119 120  | Next Page >