How to use update trigger in sql server 2008 with specific column
Hello friends currently my trigger updates on table update, and I need to change this to only fire when specific column changes.
/****** Object: Table [dbo].[User_Detail] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User_Detail](
[sno] [int] IDENTITY(1,1) NOT NULL,
[userid] [nvarchar](50) NULL,
[name] [nvarchar](max) NULL,
[jointype] [nvarchar](50) NULL,
[joinside] [nvarchar](50) NULL,
[lleg] [nvarchar](50) NULL,
[rleg] [nvarchar](50) NULL,
[ljoining] [int] NULL,
[rjoining] [int] NULL,
[pair] [int] NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[User_Detail] table data ******/
SET IDENTITY_INSERT [dbo].[User_Detail] ON
INSERT [dbo].[User_Detail] values (1, N'LDS', N'LDS Rajput', N'free', N'Left', N'jyoti123', N'SUNIL', 6, 4, 4)
INSERT [dbo].[User_Detail] VALUES (2, N'jyoti123', N'jyoti rajput', N'free', N'Left', N'mhesh123', N'priya123', 3, 2, 2)
SET IDENTITY_INSERT [dbo].[User_Detail] OFF
/****** Object: Table [dbo].[User_Detail] trigger ******/
CREATE TRIGGER triggAfterUpdate ON User_Detail
FOR UPDATE
AS
declare @userid nvarchar(50);
declare @pair varchar(100);
select @userid=i.userid from inserted i;
select @pair=i.pair from inserted i;
SET NOCOUNT ON
if update(pair)
begin
insert into Complete_Pairs(userid,pair)
values(@userid,1);
end
GO
/****** Object: Table [dbo].[Complete_Pairs] Script Date: 05/22/2014 21:20:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Complete_Pairs](
[Sno] [int] IDENTITY(1,1) NOT NULL,
[userid] [nvarchar](50) NULL,
[pair] [int] NULL
) ON [PRIMARY]
GO
my query is TRIGGER triggAfterUpdate is fired only when pair column in User_Details table is update only and when we update other column like ljoin or rjoin then my trigger is not fired
please any one can suggest us how it can done or provide solution
Jitendra Kumar Sr. Software Developer at Ruvixo Technologies 7895253402
>select @userid=i.userid
frominserted i;
select
@pair=i.pair
frominserted i;
The code above assumes a single row UPDATE.
You have to setup the trigger for set processing like when 100 rows are updated in a single statement.
UPDATE trigger example: http://www.sqlusa.com/bestpractices2005/timestamptrigger/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012
Similar Messages
-
How to use OEM to moniter sql server 2000
Hi,
I need to learn How to use OEM to moniter sql server 2000.
Can anyone help me and give me some website or documents
to read?
So I can learn to do this job.
Thanks.See Note 115302.1 in Metalink.oracle.com
in how to use OEM Diagnostic pack addon for SQL Server
Or search for
oem "user events"
to build your own monitor script. -
How to export data with column headers in sql server 2008 with bcp command?
Hi all,
I want know "how to export data with column headers in sql server 2008 with bcp command", I know how to import data with import and export wizard. when i
am trying to import data with bcp command data has been copied but column names are not came.
I am using the below query:-
EXEC master..xp_cmdshell
'BCP "SELECT * FROM [tempdb].[dbo].[VBAS_ErrorLog] " QUERYOUT "D:\Temp\SQLServer.log" -c -t , -T -S SERVER-A'
Thanks,
SAAD.Hi All,
I have done as per your suggestion but here i have face the below problem, in print statment it give correct query, in EXEC ( EXEC master..xp_cmdshell @BCPCMD) it was displayed error message like below
DECLARE @BCPCMD
nvarchar(4000)
DECLARE @BCPCMD1
nvarchar(4000)
DECLARE @BCPCMD2
nvarchar(4000)
DECLARE @SQLEXPRESS
varchar(50)
DECLARE @filepath
nvarchar(150),@SQLServer
varchar(50)
SET @filepath
= N'"D:\Temp\LDH_SQLErrorlog_'+CAST(YEAR(GETDATE())
as varchar(4))
+RIGHT('00'+CAST(MONTH(GETDATE())
as varchar(2)),2)
+RIGHT('00'+CAST(DAY(GETDATE())
as varchar(2)),2)+'.log" '
Set @SQLServer
=(SELECT
@@SERVERNAME)
SELECT @BCPCMD1
= '''BCP "SELECT
* FROM [tempdb].[dbo].[wErrorLog] " QUERYOUT '
SELECT @BCPCMD2
= '-c -t , -T -S '
+ @SQLServer +
SET @BCPCMD
= @BCPCMD1+ @filepath
+ @BCPCMD2
Print @BCPCMD
-- Print out below
'BCP "SELECT
* FROM [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername'
EXEC
master..xp_cmdshell
@BCPCMD
''BCP' is not recognized as an internal or external command,
operable program or batch file.
NULL
if i copy the print ourt put like below and excecute the CMD it was working fine, could you please suggest me what is the problem in above query.
EXEC
master..xp_cmdshell
'BCP "SELECT * FROM
[tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername '
Thanks, SAAD. -
How to enable remote connections in SQL Server 2008
I'm trying to enable remote connections in SQL Server 2008 R2 as described in the following article. I see the error message at the top of the article.
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
One step in the article describes how to enable TCP/IP in Configuration Manager. Specifically it says that
'SQL Server NETWORK Configuration' should have TCP/IP enabled.
The issue I've encountered is that my Configuration Manager
is different than what appears in the article. My Configuration Manager shows the following:
SQL Server 2005 Services
SQL Server 2005 Network Configuration (32 bit)
- Protocols for SQLExpress
SQL Native Client Configuration (32 bit)
- Client protocols
- Aliases
Note that I see 'SQL Server 2005 Network Configuration'
rather than that for 2008. When 'Protocols for SQLExpress'
is expanded, there is a TCP/IP setting, but it's disabled and I see an
Access Denied message if I try to enable this.
I also see a TCP/IP setting under Client protocols and successfully enabled this. This uses port 1433 and I configured my firewall to accomodate this port as suggested in the article.
I also followed the other steps in the article, but still don't have remote access to SQL Server 2008 R2. (I can access it from the office.) I'm wondering if this remote access issue is because SQL Server
2008 Network Configuration does not appear in Configuration Manager
and if so, I'm interested in how this might be resolved. (I'm running Windows 7 - 64 bit.)
I'd appreciate any ideas on this. Thanks.Hello,
Please refer to the following resource.
http://support.microsoft.com/kb/KbView/914277
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
How to delete the Folder from sql server 2008
Hi all,
I was trying to delete the folder from sql server 2008 with the below script
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @cmd VARCHAR(8000)
DECLARE @folderName VARCHAR(256) -- filename for backup
SET @folderName = + (CONVERT(varchar(10), GETDATE()-7, 112)) -- 7 days back date folder name
SET @path = 'I:\Backup_Test\' + @folderName -- Folder path
SET @cmd = 'del ' + @path -- Delete
EXEC master..xp_cmdshell @cmd
--Print @cmd
This is not working it was asking the Confirmation (I:\Backup_Test\20100629\*, Are you sure (Y/N)? ) what will i do to the delete the folder.
Thanks,
Prasad R.I would notice you that T-SQL does not play well to do things like that. Do not you want using .net language to delete folders?
Old method is
declare @HR int, @CFOLDER varchar(255),@FSO int
set @CFOLDER='D:\folder\'
EXEC @HR = sp_OACreate 'Scripting.FileSystemObject', @FSO OUT
EXEC @HR = sp_OAMethod @FSO, null, 'DeleteFolder', @CFOLDER
Now regarding to your second question please examine xp_fileexist system stored procedure
CREATE FUNCTION dbo.fn_file_exists(@filename VARCHAR(300))
RETURNS INT
AS
BEGIN
DECLARE @file_exists AS INT
EXEC master..xp_fileexist @filename, @file_exists OUTPUT
RETURN @file_exists
END
GO
-- test
SELECT dbo.fn_file_exists('c:\a.txt')
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/ -
Why i can not use dbco to connect sql server 2008?
Dear Experts,
i use this mehtod to link sql server 2005 :MSSQL_SERVER=tcp:mysqlserver IP MSSQL_DBNAME=SubConPayment,
it is ok,when i use this method to link sql server 2008 with dbco,it is not ok,can you tell me why i can not link to sql server2008 in sap with dbco?
looking forward to your reply.
Best regards,
MerryHi Merry,
Seems that you have to add the "provider" attribute to the connectionstring. Please have a look at the following link: [http://www.connectionstrings.com/sql-server-2008#p2]
Regards,
Ozcan. -
HI,
I have installed Cumulative Update 12 for SQL Server 2008 R2 SP2 on my SharePoint instances. This was to resolve a known issue faced with the instance. CU12 helped resolve the issue. My company is rather strict regarding security hotfixes. But I am
not sure if this particular hotfix [Security Hotfix (KB2977319)] is required if the instance has CU12 applied.
Tested this on a Lab server, the installation did run fine, the summary log also stated that the KB is applied. But the Build Number did not change. Hence the doubt.
Overall summary:
Final result: Passed
Exit code (Decimal): 0
Exit message: Passed
Start time: 2014-09-06 10:31:21
End time: 2014-09-06 10:55:49
Requested action: Patch
Instance SPNTSQLTRN overall summary:
Final result: Passed
Exit code (Decimal): 0
Exit message: Passed
Start time: 2014-09-06 10:48:08
End time: 2014-09-06 10:55:45
Requested action: Patch
Package properties:
Description: SQL Server Database Services 2008 R2
ProductName: SQL2008
Type: RTM
Version: 10
SPLevel: 2
KBArticle: KB2977319
KBArticleHyperlink: http://support.microsoft.com/?kbid=2977319
PatchType: QFE
AssociatedHotfixBuild: 0
Platform: x64
PatchLevel: 10.52.4321.0
ProductVersion: 10.52.4000.0
GDRReservedRange: 10.50.4001.0:10.50.4199.0;10.50.4200.0:10.50.4250.0
PackageName: SQLServer2008-KB2977319-x64.exe
Installation location: e:\ac2af22d88ee645b5b32b5c178\x64\setup\
Please inform if I need to apply the hotfix on CU12. Thanks in advance.
John SYes you must install Security update mentioned in KB 2977319 it is important for SQL Server to be patches with this security update. Without this it could allow an attacker to compromise your system and gain control over it.
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Articles -
How to create conditional update trigger in sql server
How to create conditional update trigger in sql server
You cant create a conditional update trigger. Once you create an update trigger it will get called for every update action. However you could write logic inside it to make it do your activity based on your condition using IF condition statement
Say for example if you've table with 6 columns and you want some logic to be implemented on update trigger only if col3 and col5 are participating in update operation you can write trigger like this
CREATE TRIGGER Trg_TableName_Upd
ON TableName
FOR UPDATE
AS
BEGIN
IF UPDATE(Col3) OR UPDATE (Col5)
BEGIN
....your actual logic here
END
END
UPDATE() function will check if column was involved in update operation and returns a boolean result
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How To Use Reporting Services On SQL Server 2000 ?
Hi all .
Today , I has a issue .
Normal , if the customer use SQl Server 2005 , it is no proplem , so if use SQL Server 2000 , Now , I want to use Reporting services on SQL Server 2000 , but , I am searching on Internet , so I know , if I want to use SQL 2000 reporting server , I must have license of SQL server 2000 .
is Every body idea for this issue ? .
Please help me .
Thanks alot .Ok ,anyway thanks alot ,.
-
Isse with using Grouping Sets in SQL Server 2008 R2
Hi,
I created a query in SQL Server 2012 using grouping sets that works fine. When I try to use the same query in SQL Server 2008 I get an error ("Inccorrect syntax near SETS").
I researched using grouping sets in 2008 and didn't see any issue with my query. What is different in grouping sets 2008 vs 2012?
SELECT tl.ClientRegionCd as [Client Region Code] , tl.ClientRegionDesc as [Region Name], count(tl.CompleteICN) as [Trauma Letters Sent]
from TORT_Trauma_Letters tl
Where CONVERT(VARCHAR(26), tl.SecondNoticeSent, 23) between '2014-06-12' and '2014-06-12'
GROUP BY GROUPING SETS((tl.ClientRegionCd, tl.ClientRegionDesc), ())
StacieCheck this blog post as how to deal with date ranges
http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/16/bad-habits-to-kick-mishandling-date-range-queries.aspx
For your result you can simply achieve your result with UNION ALL, e.g.
select Client, Region, Letters
from myTable
UNION ALL
select NULL, NULL, SUM(letters) as Letters
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
How to attach .mdf file to sql server 2008 EXPRESS
I have .mdf files created using SQL SERVER management studio 2012 in another computer and wish to attach the same to SQL SERVER 2008 EXPRESS in another computer. How should I do so? I tried this method :How
to: Attach a Database File to SQL Server Express but then it shows an error that the database cannot be created due to compatibility issues.
Msg 948: The database xyz cannot be opened because it is version 706. This server supports version 655 and earlier. A downward path is not supported..
Any help??I have .mdf files created using SQL SERVER management studio 2012 in another computer and wish to attach the same to SQL SERVER 2008 EXPRESS in another computer. How should I do so? I tried this method :How
to: Attach a Database File to SQL Server Express but then it shows an error that the database cannot be created due to compatibility issues.
Msg 948: The database xyz cannot be opened because it is version 706. This server supports version 655 and earlier. A downward path is not supported..
Any help??
You are trying to attach SQL Server 2012 database files to SQL Server 2008 R2 which is not allowed, you either need to upgrade your SQL Server 2008 to 2012 or alternatively you can generate all scripts from SQL Server 2012 and execute it in SQL Server
2008 R2.
You can refer below link to how to generate script.
http://blog.sqlauthority.com/2012/07/18/sql-server-generate-script-for-schema-and-data-sql-in-sixty-seconds-021-video/
Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
Praveen Dsa | MCITP - Database Administrator 2008 |
My Blog | My Page -
How to store Invalid Dates in SQL Server 2008
Hi,
I have SQL Server 2008 and My table has start_Date and end_date column which is DATETIME datatype.
Somehow my table is having invalid dates which is lesser than 1753-01-01 00:00:00.0 range.
I want to know how this date get inserted in the SQL Server.
Thanks,
MuthuprabhuCan you post the DDL for that table together with a SELECT query and results demonstrating invalid data?
DECLARE @dt DATETIME = '1753-01-01 00:00:00.0';
-- Command(s) completed successfully.
DECLARE @dt DATETIME = '1752-01-01 00:00:00.0';
Msg 242, Level 16, State 3, Line 4
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Datetime conversion:
http://www.sqlusa.com/bestpractices/datetimeconversion/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
How to Configure Remote Connections To SQL Server 2008 R2 Express
Post written June 10, 2010 and pertains to:
SQL Server 2008 R2 Express on both my server and local machines: SQLX_SRV,
SQLX_LOC
SQL Server 2008 R2 Management Studio on both my server and local machines:
MS_SRV, MS_LOC
Windows Server 2008 R2 Enterprise installed on a Hyper-V VPS: WS
SQL Server Configuration Manager on both my server and local machines:
CMGR_SRV, CMGR_LOC
Server Manager: SMGR
I am connecting to my hosting server via Remote Desktop Connection: RDC
I installed SQLX_SRV and MS_SRV on my hosting server and SQLX_LOC and MS_LOC on my local development machine. I am able to use MS_LOC to connect to SQLX_LOC and to use MS_SRV to connect to SQLX_SRV. However I am not able to use MS_LOC to connect
with SQLX_SRV. Here's what I have done so far:
SMGR -> Configuration -> Windows Firewall to turn off the Windows Firewall for Domain, Private and Public profiles. Obviously I'll change this later, but until I can connect I want to remove as many variables as possible.
CMGR_SRV -> SQL Server Services to confirm that both SQL Server (SQLEXPRESS) and SQL Server Browser services were running.
CMGR_SRV -> SQL Server Network Configuration -> Protocols for SQLEXPRESS to ENABLE the Shared Memory, Named Pipes, and TCP/IP protocols and DISABLE the deprecated VIA protocol.
CMGR_SRV -> SQL Server Network Configuration -> Protocols for SQLEXPRESS -> double click TCP/IP to open the TCP/IP properties dialogue. On the Protocol tab Enabled: Yes, Keep Alive: 30000, changed Listen All to No. I've tried it both
ways, but I've got six IP addresses on my server and I wanted to configure SQLEXPRESS to listen to only the first and primary IP. On the IP Addresses tab went to IPALL and cleared the TCP Dynamic Ports field and entered 1433 in the TCP Port field.
For my first and primary IP Address I made sure that Enabled was Yes, I cleared the TCP Dynamic Ports field, and entered 1433 in the TCP Port field. For all other IP Addresses Enabled was set to No and I cleared both the TCP Dynamic Ports and TCP Port
fields.
CMGR_SRV -> SQL Server Services -> SQL Server (SQLEXPRESS) right click and Restart. This of course stopped and restarted my instance of SQLX_SRV enabling the TCP/IP configuration in the previous step to take effect.
On my server, SQLX_SRV is the only instance of SQL Server running and so it's easy to hard wire it to the default port 1433.
The instance name for both SQLX_SRV and SQLX_LOC is the default "SQLEXPRESS". My server machine name is "SERVER1" on the EnglishBrains.com domain. So the proper local name (local within the context of my remote server as connected via RDC) for
my instance of SQLX_SRV would be:
SERVER1\SQLEXPRESS
Note the use of a backslash NOT a forward slash.
Of course to connect remotely from my development machine, which is not on the same domain as my hosting server, I would need to specify the domain as well, so the SQL Server name becomes:
SERVER1.EnglishBrains.com\SQLEXPRESS
I must also use SQL Server Authentication. Before I can use such a remote connection, however, there are still several configuration steps required. So on my server (connected via RDC) I used MS_SRV to connect to SQLX_SRV using SERVER1\SQLEXPRESS
for the server name and Windows Authentication. Once connected I performed the following steps:
MS_SRV -> right click the connected parent SERVER1\SQLEXPRESS instance node at the top -> Properties -> Security -> Server authentication: select "SQL Server and Windows Authentication mode". This will enable connections using either type
of authentication.
Next, leaving the Server Properties dialogue open, Connections -> check "Allow remote connections to this server" box.
Click OK to save these changes and close the Server Properties dialogue.
MS_SRV -> Security -> right click Logins and select "New Login...", the Login - New dialogue opens.
On the General page Enter a name for your new login
Select SQL Server Authorization
Enter and confirm a password
Uncheck Enforce password expiration
Select the default Database and Language
On the ServerRoles page Public will be checked, also check SysAdmin. This is probably not a good idea and I'll uncheck this as soon as I can connect to the SQLX_SRV.
On the User Mapping page select the databases you want your new Login to access and enter the Default Schema of "dbo".
At the bottom of the User Mapping page you'll see the Database Roles table. Public will be selected by default. Also select db_Owner. Again this is probably not a good idea, and I'll refine this once I can connect.
On the Status page confirm that "Grant" is checked under "Permission to connect to database engine" and "Enable" is checked under "Login".
Click OK to save all changes and close the Login - New dialogue.
With these steps completed you should now be able to use MS_SRV to connect to SQLX_SRV using SQL Server Authentication by supplying the name and password for your new Login. I tried this and it worked fine. Next I tried to use this same login
remotely, that is I went to my local development machine and used MS_LOC to try and connect to SQLX_SRV by using
SERVER1.EnglishBrains.com\SQLEXPRESS
and opting for SQL Server Authentication and supplying the name and password of my new login.
THIS DID NOT WORK?? Instead I get the following error message:
Cannot connect to SERVER1.EnglishBrains.com\SQLEXPRESS.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider:
SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)
For help, click:
http://www.microsoft.com/products/ee/transform.aspx?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1
If you follow the suggested help link, you are told:
The SQL Server client cannot connect to the server. This error could be caused by one of the following reasons:
A specified SQL Server instance name is not valid.
The TCP, or named pipes protocols are not enabled.
The firewall on the server has refused the connection.
The SQL Server Browser service (sqlbrowser) is not started.
WRONG on all 4 counts! The instance name IS valid. Both TCP/IP and Named Pipes protocols are enabled. The firewall has been shut down, so it is not relevant. Finally the SQL Server Browser IS started.
The next thing I tried was to circumvent discovery by the SQL Browser service by using the following syntax to specify the IP address and port directly when specifying the SQL Server name.
tcp:68.71.134.186,1433
Using this in the Server Name field I was able to use MS_SRV to successfully connect to SQLX_SRV (using SQL Server Authentication of course) with or without the SQL Browser service running.
However when I tried to connect from MS_LOC to SQLX_SRV using this same login (WITH SQL Browser service running just for good measure) it does not work?? I get the following error message:
Cannot connect to tcp:68.71.134.186,1433.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider:
TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=10060&LinkId=20476
If you follow the help link you are told:
"The SQL Server client cannot connect to the server. This error could occur because either the firewall on the server has refused the connection or the server is not configured to accept remote connections."
However, the firewall has been shut down and the server HAS been configured to accept remote connections!
I confirmed that i could indeed Ping to 68.71.134.186 and running NetStat -a |find /i "listening" on the server shows that the server is indeed listening at 68.71.134.186 Port 1433 -- which is why I was able to connect to SQLX_SRV using MS_SRV with
tcp:68.71.134.186,1433 .
IN SUMMARY: Even though I can connect to my SQLEXPRESS instance multiple ways from the server itself, I cannot connect remotely from my development machine!
If anyone can help me figure out why I would be very, very grateful!My two cents to help you out on c# code example to configure the remote sql server express.
Hope it helps. It works, but you have to be extra carefull to read it all and setup the server configuration and netsh commands; also the port fowarding on the router.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace sqlremoteconnection
class Program
static void Main(string[] args)
// this is the local sql server connection
// 192.168.1.101\SQLEXPRESS
// now, the configuration for remote access:
// activate SQL SERVER BROWSER - set it to start "automatic"; then START UP
// SQL Server Configuration Manager
// --> SQL SERVER BROWSER -> properties -> Service -> Start Mode -> automatic -> apply
// --> Log On -> Start -> Ok
// netsh firewall set portopening protocol = TCP port = 1433 name = SQLPort mode = ENABLE scope = all profile = CURRENT
// netsh firewall set portopening protocol = UDP port = 1434 name = SQLPort mode = ENABLE scope = all profile = CURRENT
// netsh advfirewall firewall add rule name = SQLPort dir = in protocol = tcp action = allow localport = 1433 remoteip = any profile = PUBLIC
// netsh advfirewall firewall add rule name = SQLPort dir = in protocol = udp action = allow localport = 1434 remoteip = any profile = PUBLIC
// VERY IMPORTANT FOR REMOTE ACCESS: you have to add the rules on port fowarding
// on the router!!!
// TCP: 1433
// UDP: 1434
// or just a personal port like TCP 31433/UDP 31434
// read carefully the netsh commands above
// server name: 123.132.24.177\SQLEXPRESS
// server name: anyurl.myftp.org\SQLEXPRESS,1433 <<-- regular port
// server name: anyurl.myftp.org\SQLEXPRESS
// server name: anyurl.myftp.org\SQLEXPRESS,31433 <<-- WOW different PORT here!!!
SqlConnection myConnection = new SqlConnection(
"user id=sa;" +
"password=password_goes_here!;" +
"server=anyurl.myftp.org\\SQLEXPRESS,31433;" +
//"Trusted_Connection=no;" +
"database=database_name_here; " +
"connection timeout=30");
try
myConnection.Open();
catch (Exception e)
Console.WriteLine(e.ToString());
try
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select * from mytable", myConnection);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
Console.WriteLine(myReader["tab01_name"].ToString());
Console.WriteLine(myReader["tab01_age"].ToString());
catch (Exception e)
Console.WriteLine(e.ToString());
try
myConnection.Close();
catch (Exception e)
Console.WriteLine(e.ToString());
Adelino Araujo -
How to enable high availability on SQL Server 2005 with Windows Server 2008 Enterprise R2
Dear Folks,
I would like to ask you about this thing. I'm working for IT department for bank in Myanmar. Our bank have up to 96 branches across all of Myanmar including H.O. We are using Microsoft SQL Server 2005 with Windows Server 2008 for our banking
information system. My main problem is having to backup and restore the database backup files every time the servers in branches goes down for whatever reasons. I want to deploy this feature of high availability and failover cluster using Windows Server 2008
and SQL Server 2005. Our branches have 2 Servers. One is for Primary and other is for Backup. What I want to do is that, I want to change Backup Server to Primary Server whenever the Primary Server goes down for whatever reasons. All the working data and databases
from Primary will immediately replicated into Backup Server along with all the IP information of Primary Server. Please give me step by step guide for this process.Try below
http://blogs.msdn.com/b/cindygross/archive/2009/10/23/checklist-for-installing-sql-server-2005-as-a-clustered-instance.aspx
I will recommend you to upgrade SQL server to newer version for support as well as flexibility.
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
How to Migrate Stored procedure on Sql server 2008 to Oracle Database
Guys, I need help vey badly as I am new in this field.
Problem is that, I have to migrate stored procedure on Sql server 2008 to oracle Oracle database:
Whole scenario--
1. Sql Server 2008 application on Windows server (source machine)
2. I have to migrate 70 Stored Procedure
3. To Oracle Database on Linux machine (Target machine)
Any method (no problem)
Please, help me or give me any reference as I don't know which keyword is differ in both database.
Thanks in advanceHi,
You could the free Oracle SQL*Developer to do this.
There is information and a download link here -
Oracle SQL Developer</title><meta name="Title" content="Oracle SQL Developer"><meta n…
and information on using it for migrations here -
http://www.oracle.com/technetwork/database/migration/index-084442.html
You could use it in 2 ways -
1. Go through a migration but just pull the stored procedure code from the file created after you generate the SQL from the SQL*Server database
2. Use the scratch editor accessed from -
- Tools - Migration - Scratch Editor
and paste the SQL*Server stored procedure code into the window and it will convert it to Oracle code. The tool is very good but may have problems if you have very complicated procedures that use SQL*Server specific utilities.
Regards,
Mike
Maybe you are looking for
-
App Store gives "An unknown error has occurred" when I try to log in
I know I'm using the correct username and password -- using a different one gives a password-specific error, and the username/password works correctly elsehwere. I have applied all updates, and rebooted. I just had my SSD replaced (got the machine ba
-
MacBook Pro won't boot after trying to install 10.7.3 update. Start up stalls at Apple logo and spinning gear. Computer won't even start in safe mode.
-
Which method (if it exists) can i use if I want to convert my hexadecimal input to a binary format that is compatible with DES operations?
-
Iphoto thumbnails not matching photos
Just back from a trip and uploaded all our photos, and thought they were all out of order when looking at the thumbnails, but when I click on a thumbnail, it's actually a different photo completely. HELP! Don't want to lose all our photos, what's
-
Sony Vaio crashing Photoshop/Illustrator CS6 on startup
Hello everyone, I've searched a bit to try and find a work around for this issue on my new Sony Vaio Flip 15 but I can seem to find a permanent solution. I recently installed CS6 Web/Design Suite on this laptop and every time I go to start Photoshop