I am using SQL Server 2012 on Windows Server 2012.
I am using SQL Server 2012 on Windows Server 2012.
Hi, I'm a junior DBA, I want to learn much more about SQL server. Now I didn't get any clear explanation about SCHEMA. Can you please explain it easily with a simple example.
also the difference between mssql schema and mysql schema
I want to achieve MCSE - BI certification, according to its path i need to pass all 5 papers.
70-461,70-462,70-463,70-466,70-467
I cleared 70-466 exam few month ago. When I am checking my certification activity, it is suggested that I have missed 70-461,70-462 and 70-463 exams. BecauseI already have MCSE - Data plateform 2012 certification and passed all 3 exams my questions are
Q1 Why I need to pass these exams again?
Q2 Can I upgrade MCSE - 2012 certification to MCSE - 2014 with exam codes?
Shamas Saeed (if Post helpful please mark as Answer) http://shamas-saeed.blogspot.com
private void LoadDataGridView(int ID) { try { SqlConnection connection = new SqlConnection(connString); SqlCommand cmd = new SqlCommand("SELECT SENTENCE FROM Sentences WHERE CategoryID = @ID",connection); cmd.Parameters.Add("@ID",SqlDbType.Int).Value = ID; DataTable dataTable = new DataTable(); SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd); dataAdapter.Fill(dataTable); DataGridView.DataSource = dataTable; } catch (Exception) { MessageBox.Show("ERROR WHILE CONNECTING TO DATABASE!"); } }
private void RefreshBtn_Click(object sender, EventArgs e)
{
try
{ SqlConnection connection = new SqlConnection(connString); SqlCommand cmd = new SqlCommand("SELECT SENTENCEFROM Sentences WHERE CategoryID IN(@CategoryID)", connection); cmd.Parameters.Add("@CategoryID",SqlDbType.Int).Value = CategoryID; SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd); SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(dataAdapter); dataAdapter.Update(dataTable); } catch (Exception) { MessageBox.Show("ERROR WHILE CONNECTING WITH DATABASE!"); } }
Hi, new to this...and limited experience of SQL Server and MS Access.
I am trying to import a database that I have created in MS Access 2016 into SQL Server 2016.
It appears that you are unable to import .accdb files into SQL Server and also unable to save a database created in Access 2016 as a .mdb file??
Anyone have any ideas ? - It's part of a college assignment and time is not on my side....I am trying to avoid a situation where I have to manually recreate the Tables in SQL Server.
Thanks.
Hi All,
Is it possible to exclude certain tables to be replicated/synchronized by AlwaysOn?
Thanks.
Hi All,
I wanted to mention a de - duplication logic which we are performing in our database. We are having some data in table1 and I want to apply de duplication logic if there is any duplicate data in table1.
E.G: I have the below data in table1
ID | Roll | Number1 | Number2 | Number3 |
100 | 1 | 50 | 75 | 44 |
200 | 1 | 45 | 68 | 99 |
200 | 1 | 65 | 98 | 22 |
300 | 1 | 98 | 65 | 31 |
400 | 1 | 58 | 35 | 58 |
500 | 1 | 69 | 47 | 64 |
500 | 1 | 35 | 85 | 71 |
500 | 2 | 14 | 65 | 25 |
600 | 1 | 36 | 14 | 39 |
600 | 2 | 25 | 99 | 54 |
700 | 1 | 14 | 69 | 96 |
If ID & Roll are same for a record they will be treated as duplicate. In this example, ID 200 & Roll 1 and ID 500 and Roll 1 are duplicate. The logic is when the system finds duplicate records it will sum up Number1, Number2 & Number3 for duplicate records and only single(unique) row will be inserted into Table2. That means, the below data will take place in Table2.
100 | 1 | 50 | 75 | 44 |
200 | 1 | 110 | 166 | 121 |
300 | 1 | 98 | 65 | 31 |
400 | 1 | 58 | 35 | 58 |
500 | 1 | 104 | 132 | 135 |
500 | 2 | 14 | 65 | 25 |
600 | 1 | 36 | 14 | 39 |
600 | 2 | 25 | 99 | 54 |
700 | 1 | 14 | 69 | 97 |
I want a single query which will show me that the duplicate records are inserted properly in Table2. For example, the query has to prepare in such a way so that it returns 0 if all the duplicate/non duplicate records are inserted properly in Table2. please let me know if it doesn't make sense.
Thank You in advance!!
JPP
Hello,
I am trying to create a table containing the results of a query with lots of JOINs. I'm using SELECT...INTO. The statement runs and tells me that the correct number of rows were affected, but it doesn't create the table. I'd like opinions on why it's failing.
The query runs properly and produces the expected results without the INTO clause.
My query is:
USE MarketingAnalysis_BAK
GO
ALTER DATABASE MarketingAnalysis_BAK SET RECOVERY BULK_LOGGED;
GO
IF OBJECT_ID('dbo.RawData_SteelPoles', 'U') IS NOT NULL
DROP TABLE dbo.RawData_SteelPoles;
GO
SELECT (a long series of columns)
INTO dbo.RawData_SteelPoles
FROM (a long series of joined tables)
GROUP BY (a long series of columns)
;
GO
ALTER DATABASE MarketingAnalysis_BAK SET RECOVERY FULL;
GO
-- Thanks in advance.
I have code that I created that I want to get all the orders NOT ordered in a certain timeframe. I am using the following code:
SELECT
*
FROM
CL_OSQ_BLOCK
WHERE
notEXISTS
(select*fromtbl1
WHERECL_OSQ_BLOCK.ORDERSET_ID =
tbl1.PRL_ORDERSET_ID
My question is how can I get ALL the fields from tbl1 instead of or in addition to the fields from cl_osq_block?
Right now it runs, but only gives me the fields from whatever table I use before the subreport. I created a CTE- tbl1, that has all the fields I need but cant figure out how to get to them when using the not exists.
FROM
CL_OSQ_BLOCK
WHERE
notEXISTS
(select*fromtbl1
WHERECL_OSQ_BLOCK.ORDERSET_ID =
tbl1.PRL_ORDERSET_ID
Hi,
I tried following steps.But i could not able to connect SQL Server management studio 2012 using ip address.I am using default instance name.
1.Enable TCP/IP connection & set TCP port 1433 in SQL server configuration manager.
2.Set firewall inbound & outbound rules to allow TCP & UDP port connection.
3.Allow the remote connection in SQL Server management studio 2012 also.
4.Enable Filestream property in the SQL server services of SQL server configuration manager.
I used to connect SQL Server management studio 2012 by giving server name as "ip address\defualt instance name" & Authentication as "SQL server Authentication" & username as "sa" & password.
Can anyone know the solution , let me know.
Thanks,
Priyankamurali
Dear all,
I have a table with such data :
ColAColB colCMontant DateFrom
AAABBB CCC1234 2015-01-01
AAABBB CCC1278 2016-01-01
DDDEEE FFF7654 2015-01-01
HHHIII JJJ2861 2014-01-01
AAABBB CCC647 2014-01-01
DDDEEE FFF2931 2015-09-01
I need to have a result like this :
ColAColB colCMontant DateFromDateTo
AAABBB CCC1278 2014-01-012015-01-01
AAABBB CCC1234 2015-01-012016-01-01
AAABBB CCC647 2016-01-01NULL
HHHIII JJJ2861 2014-01-01NULL
DDDEEE FFF7654 2015-01-012015-09-01
DDDEEE FFF2931 2015-09-01NULL
If multiple lines with combination of colA, colB and ColC, then the DateFrom of second line must become the DateTo on first line
and null if not multiple line
Is there a way to do this ?
thanks in advance.
regards
Hi, My management team wants a report of SQL server shutdown and startup times for last 6months, in my event log I have last 3 months records only. Please help me to get this done.
HI guys,
I have one case .
I have 10 emp who have status=A
in that out of 10 we have 5 emp also having status= B
I that out of 5 we have 3 emp also having Status = C
So i want only emp who have Status =A not in B OR C
AND Emp having Status BOTH (B,C)
Please give me the solution result will be 8 rows.
Hello,
I have acquired a .sql script that creates a temporary table, populates it, and then uses it to populate a second table. It supposedly worked correctly before I received it. But now when I run it, I received an error message.
The script is as follows:
DECLARE @MaxThinning TABLE
(
CID int NOT NULL,
LegConditionId int NOT NULL,
InspectionID int NOT NULL,
ThinningAmount numeric(5,2),
CorrosionPresent bit NOT NULL
);
--Select data into temp max thinning table
INSERT INTO @MaxThinning
(
CID,
LegConditionId,
InspectionID,
ThinningAmount,
CorrosionPresent
)
SELECT dbo.OUS_LEGCOMPONENT.CID,
dbo.OUS_LEGCOMPONENT.LegConditionId,
dbo.OUS_LEGCONDITION.InspectionID,
MAX(dbo.OUS_LEGCOMPONENT.OriginalThickness - dbo.OUS_LEGCOMPONENT.EffectiveThickness) as ThinningAmount,
MAX(CAST(dbo.OUS_LEGCOMPONENT.CorrosionPresent as int))
FROM dbo.OUS_LEGCOMPONENT INNER JOIN
dbo.OUS_LEGCONDITION ON dbo.OUS_LEGCOMPONENT.CID = dbo.OUS_LEGCONDITION.CID
AND
dbo.OUS_LEGCOMPONENT.LegConditionID = dbo.OUS_LEGCONDITION.LegConditionID
GROUP BY dbo.OUS_LEGCOMPONENT.CID,
dbo.OUS_LEGCOMPONENT.LegConditionId,
dbo.OUS_LEGCONDITION.InspectionID
;
GO
IF OBJECT_ID('dbo.RawData_SteelTowers', 'U') IS NOT NULL
DROP TABLE dbo.RawData_SteelTowers;
GO
--Create the final dataset; finish by joining to temp table to get max values
SELECT (long list of columns),
g.CorrosionPresent,
g.ThinningAmount
INTO dbo.RawData_SteelTowers
FROM (list of tables) INNER JOIN,
@MaxThinning g ON b.LegConditionID = g.LegConditionId
AND
b.CID = g.CID
GROUP BY (long list of columns),
CorrosionPresent,
ThinningAmount
;
GO
The message I get back is:
(54043 row(s) affected)
Msg 1087, Level 15, State 2, Line 34
Must declare the table variable "@MaxThinning".
My thought is that I AM declaring the table variable "@MaxThinning". But apparently it's not working. What am I missing?
Thanks.
WHEN I BACKUP THE DATABASE IN SQL SERVER 2000, I AM NOT ABLE TO GET THE COMPLETE BACKUP. IN OTHE.R WORDS, WHEN I RESTORE THE BACKUP IN SOME OTHER COMPUTER, THE DATA I CAN SEE IS NOT COMPLETE.
SINCE MY DATA IS GROWING EVERY PASSING DAY AND THE DATABASE IS WORKING FINE, THEREFORE THE SIZE OF BACKUP SHOULD ALSO INCREASE EVERYDAY. BUT EVERY TIME I CREATE A BACKUP, THE SIZE OF BACKUP REMAINS THE SAME AND CONTAINS THE SAME DATA (WHEN I RESTORE IT IN SOME OTHER COMPUTER.
PLEASE GIVE A SOLUTION
THANKS
RAJAN KAPOOR
Hi Friends,
I have following tables in my datawarehouse. it is snowflake schema. i want too make it star schema. As solution what is better to add one column in fact table that reference to dimensionTransaction directly or remaing as it bellow? What is the best idea?
There are two tables to be joined but there is no column column.
Table 1:-
It has the following columns in the image.
The 2nd table has the following columns:-
Now my question is in Table 1, there is a sql_count columns where there are list of sql count script listed. I executed each script by doing a union all and below is the result for that.
My question is, I need to put this result set in place of Sql_count columns and build a query in such a way which has, ID ( from table 1), Date (from table 2) , Name (from table 1), Type (from table 1), Description (from table 1), SQL_Count(From Union all query , Image 3) , SQL_impact(from table1), DataLink (From table 1).
I have done a cross join which you can see in table 1. Please advice if its correct way. Can you guys please give me a query on this please?
Your inputs will help me a lot as I am new to this.
Thanks.
Karan Sheth