SQL

SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.

Share tech news, updates, or what's on your mind.

Sign up to Post

Help me on this sql.

I have the two tables
batch_info
document_info

i need to update the STATUS = 'COMPLETED' IN Batch_info table
where the module name is = 'EXPORT' Based on Document_info table
where the release ='1' record.

Here is the example.

Batch_info

EXTERNALBATCHID,NEXTMODULE,NEXTSTATUS
36267,EXPORT,READY
36264,EXPORT,READY

Document_info
DOCGUID,RELEASED,EXTERNALBATCHID
{B7FE744A-DE4D-4b1d-AEFA-65C3F40B2608},1,36267
{CDAAD0C0-AF11-4b53-97CF-C00D62C50F98},1,36264


Regards,
Praveen
0
Get your Disaster Recovery as a Service basics
LVL 1
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

I'm not sure what I'm asking, so part of my question is to help me understand what I'm talking about. :)

We're trying to import a SQL Server 2008 DB into SQLAzureMW. However, once it imports, I found the "Default Value or Binding" settings for all our tables aren't coming through when those values are (from what I can see) a default value we somehow, and for some reason, created? (Our DB Admin left years ago.)

I can make such dummy "defaults" in SQL Management via commands lines like this...

create default dbo.MyOwnGUID as newid();

After I run that, now if I go into a table's design, select a column, click on "Default Value or Binding", and then click on the dropdown arrow, my new "default" creation of "dbo.MyOwnGUID" is now listed as an option to select.

First question: What exactly are these things called!? Are they just called "defaults"? (At first I thought "default constraints" but that appears to be something else, as they don't appear in sys.default_constraints.)

Second, where can I see a list of all these "defaults" we created in our DB years ago? I'd like to see them graphically in Management Studio, but maybe it's not an option, and it requires SQL.

And third, are these considered good or bad practice? (I only ask because it seems odd they won't import into SQLAzureMW. However, I can save that problem for another post, as I need to first figure out what's going on.)
0
i have developed application using vb.net. which have sql server 2008 database and also includes crystal reports. and i want to create .exe of project. For distribution. I am trying to do this with visual studio 2010.. Using traditional method..by selecting Setup And Deployment Projects..but after clicking on primary output it give message like.."" The following files may have dependencies that can not be determinited automatically. Please confirm that all dependencies have been added to the project c:\windows\system32 \macromed\flash\flash.ocx..""  Please help me to solve this..
0
SELECT FTR_SORTORDER,LINEITEM_SORTORDER,LINEUP,LINEUP_DESC,HRS,DESIGN,PROCESS,NC_PRG,CHK_HRS,MATL_CST,
       (HRS + Design + PROCESS + NC_PRG + CHK_HRS) TOT_US
FROM (
SELECT get_secc_hourlyrate(10022) GHRLY_RATE from dual,
(TOT_US + GHRLY_RATE) + MATL_CST / 1000 HRLY_RTE
JOIN
SELECT f.STM225_SORT_ORDER_R FTR_SORTORDER, l.STM108_SORT_ORDER_R LINEITEM_SORTORDER, f.STM225_FTR_C LINEUP,


IS THIS THE QUERY COREECT>
CHECK 5 LINE
0
We have a job that runs every 15 minutes it sends emails to specific recipients from the db using xp_sendmail sql 2000.  Last night it starting sending the same email every 1 minute, and we cannot stop it.  We have restarted the server and it still continues.  We have no idea what to do at this point, any ideas would be great help.
0
I do not know how to use SQL or VBA.  (I used to write scripts in Borland dBase a long time ago, but I've atrophied since then.)   I can build somewhat complex databases, queries, and reports using tables in Access.  I frequently use Excel data tables as Access data sources.  And I can build basic Excel spreadsheets using many of the built-in functions.  I currently have a large database I need to analyze.  Each line in my Access table has one set of parameters (3 to 5 numbers) that needs analysis (return one number).  The analysis for that one set of parameters is too difficult to perform in Access using a long series of queries, and I doubt I could construct it.  Although it will take some time to build the spreadsheet in Excel, it should be straight forward to do the calculations and make the final decision in Excel on a single set of parameters.  However, there is no way I could construct that on a single Excel line, and then repeat that line down hundreds of thousands of lines in Excel.

How can I pass one set of parameters, say 5 numbers, to 5 specific cells in an Excel spreadsheet, and read  the result cell back into Access?  Running the Access query will need to complete the same analysis on every line in the Access data table, and fill in the results column in the same Access parameters table or a different Access table linked to the original parameters table.  Just to be clear, I'm not asking how to use a single Excel internal function, such as Present Value, in …
0
My database is configured with Full recovery mode and use tools inside MS SQL to backup the database.

Should I need to configure anything to truncate / remove the log after the backup ? Will these logs be removed automatically after the backup ?

Thx
0
I am working with a third-party MySQL database.  I am trying to decode a field.  This field contains the IP address of a computer.  I have been told this field is in base64 format.  I am not able to figure this out.  Below I have an example of some methods that I have tried using, with no luck.  

select 
    ip,
    from_base64(ip),
    inet_ntoa(ip)
from datbasename.device;

Open in new window


I am running MySQL 5.6.32.

Does anyone have any suggestions on how I can decode these values?

Many Thanks!
0
I have a pl/sql  procedure this is the code:
PROCEDURE get_docClob(OFFSET IN NUMBER, opcDoc OUT VARCHAR2)
   IS
d VARCHAR2(5000);
BEGIN
    SELECT DBMS_LOB.substr( doc, 4000, OFFSET) INTO d
    FROM docClob
    WHERE ROWNUM <  2;
    opcDoc := d;
END ;  
I've tested it pl/sql developer with offset = 1 and doesn't return any thing and doesn't raise any errors.
I tested it in sql using this code:
SELECT DBMS_LOB.substr( doc, 4000,1)
FROM docClob
WHERE ROWNUM = 1;
and it returns the first 4000 characters of the clob.
0
I see bit of code:

SELECT TOP 1 *

What is the difference between that VS simply doing this:

SELECT TOP 1 *
1
Get your Conversational Ransomware Defense e‑book
LVL 1
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Hi

Following on from this post Wordpress SQL query help

Each post 'should' have multiple entries (30--50 on average) in wp_postmeta as a result of running the previous  I've now discovered some where the metadata is missing

using the sample data in  the last post how find all the post which have less than 5 ?

In sudo code

select p.`ID`,p.post_title
from wp_posts p, wp_postmeta m 
where p.post_status ='publish' and 
p.`ID`= m,post_id in (select post_id from wp_postmeta where count(m.meta_key) <=5) 

Open in new window

0
Hi Experts,


I have a case when statement
when cce.CVA_StatusID is not null then cvs.StatusType else 'No Status' end as [Status]

Open in new window


and would like to do:
INNER JOIN  @SEV as sta on sta.stat = Status

But one can see this is not the correct way to do this.

Any idea would be great?  Maybe a CTE?  but would need help.

Thank You....
0
So, a client would like to be able to have their employees receive a message if they haven't entered in time within the last 7 days. Specifically Monday - Monday at 12:00PM. If the employees have not entered in time by noon, they should be locked down and only allowed to enter time for dates that fall within the last 7 days. The code is written in VB.NET and utilizes SQL and Stored Procedures heavily. I was hoping to get some ideas in regards to possible ways to go about this.
0
how to update column of 1 table from column of another table  without having any reference
0
Hi Guys,

I need help with a SQL query / script,

We have two tables,
SQL TABLE 01 - with primary employee records , identified by the person's ID number.
SQL TABLE 02 - with multiple records for each employee, relating back to the primary table by employee ID number.

Ideally I would like to extract the information to Text / CSV for only a specific list of employee ID numbers.

For example:  
A text file (A) with 1000 employee ID numbers.
A script to read the text file (A), do a lookup on each employee in SQL TABLE 01.  Write the result to another text file (B).
The same script to lookup the same employee records by ID number in SQL TABLE 02, write all relating records to Text File (B).

Thus, the text file (B) will have primary and secondary employee records from the list of employee ID numbers in text file (A).
0
Dear All

We have some servers physical and Virtual with WIn 2012 R2 installed.
SQL server has been installed.

Now issue is all server memory is going above 90% and servers are very slow.
0
My Tables has the following fields:
ERRC, Stock Nbr, Count of Stock, Qty Requested and Qty of Stock.

My query needs to group by ERRC, count records for each ERRC, Count Unique Stock for Errc, multiple unique stock * Qty request
0
How should I add two auto increment column in a table
0
Hi All,
I need your help. I have the query below but I do not think is working as expected.

The business rule is that Date1 must be the earliest date, if not then show all records where Date1 is not the earliest. I started with this query but I think it needs some twitching to work, could you please help.
 

SELECT f.id_number,f.status,E.Date1,E.Date2,E.Date3,E.Date4,E.Date5,E.Date6
CASE
    WHEN E.Date1 > E.Date2      THEN 'Date2'           || ' ' ||  E.Date2
    WHEN E.Date1 < E.Date3      THEN 'Date3'            || ' ' ||  E.Date3
    WHEN E.Date1 < E.Date4      THEN 'Date4'             || ' ' ||  E.Date4
    WHEN E.Date1 < E.Date5      THEN 'Date5'           || ' ' ||  E.Date5
    WHEN E.Date1 < E.Date6      THEN 'Date6'       || ' ' ||  E.Date6
         END AS THE_DATE
FROM
       TableE E
LEFT JOIN TableF F
       ON F.id_number = E.id_number  
WHERE E.Date1  IS NOT NULL
0
NFR key for Veeam Backup for Microsoft Office 365
LVL 1
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

I need to create a tabbed report in SSRS that displays totals by Customer. See the attached report layout. Tab 1 would be Net Open Sales. This is the top left report in the attached example.

My question/Issue is how do I write the query to make this dataset easy to use in SSRS Report Builder?

For example my Customers are arranged in Alpha order however JC Penny and Kohl's are listed only once on the report however in the database I need to sum them because there are two ID's. One for in-store and one for ecommerce.

This is what I began with however it gives me the same total for every record for KOHLS. More importantly I'll need a sub-total minus walmart and a grand total. I'm not certain that I'm approaching this correctly.

SELECT  ( SELECT    SUM(price * total_qty)
          FROM      [KLL Open Orders - Header & Detail]
          WHERE     ( ( CUSTOMER IN ( 'KOH0010', 'KOH0015' )) )
                    AND ( (division = 'KLL') )
                    AND ( (end_date > = DATEADD(DD, -30, GETDATE())) )
                    AND ( ( ORD_STATUS = 'O' ) )
        ) AS KOHLS2017
FROM    [KLL Open Orders - Header & Detail];

Open in new window

Capture.JPG
0
It's time to update sql server.  But I can't access the databases on this instance of sql server 6.5.  See image for error.  Notice there is a green light, but when I try to expand, I get the error.  Interestingly, the legacy program that is associated with the databases on this instance runs just fine.  Any ideas how I can get to the data via enterprise manager?
error message
0
I have a program that uses sql server database.  When I try to log in the first time it gives me a Login timeout expired window.   I click ok and then try to login again and it works.  Any ideas how to fix this??
0
Hi experts,
Could you please help. How to identify table row inserted or updated date & time using oracle way. E.g system column etc. and without using archive log or flash back files

Since this is a custom table and we don't maintain created or last updated column defined. So could you pls help

Oracle Database 11g
0
Hi. I want to add some values in SQL on the basis of  some other condition(something like using sum-if in excel). Below is the example:

I have a table with three columns using which I want to calculate the total product value and store the value in a column with respect to Bound Status and keeping values for other statuses as Zero.

Input Table:

Product      Status      Value
ABC-01      Bound      10
ABC-02      End              12
ABC-03      Canc      -2
DEF-01      Bound      15
EFG-01      Bound      20
EFG-02      Canc      -15

Output Table:

Product      Status      Value      Final Value
ABC-01      Bound      10            20
ABC-02      End              12              0
ABC-03      Canc      -2             0
DEF-01      Bound      15           15
EFG-01      Bound      20             5
EFG-02      Canc      -15             0

Thanks
0
Hi,

Previously I was able to make use of an sysadmin account on our client's server to create jobs and execute packages. The client has now changed the rights of this account so it's not a sysadmin anymore and now the jobs are failing. They don't want to give me another sysadmin account. I now need to know how do I go forward in giving this new account permissions to run Sql Server Agent jobs and to execute packages. The account they have created for me is not a windows login but only a sql login.

Regards
Christian
0

SQL

SQL (Structured Query Language) is designed to be used in conjunction with relational database products as of a means of working with sets of data. SQL consists of data definition, data manipulation, and procedural elements. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control.