Wednesday, March 21, 2012
Quotes
procedure ?
Ex1: where username = @.username
AND status = "D" -- or 'D'
Ex2: if @.stringtype = "D" -- or 'D'
Select ...............
Thanks.
See "SET QUOTED_IDENTIFIER" in BOL.
Example:
use northwind
go
set quoted_identifier off
go
select 1
where
"1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
go
set quoted_identifier on
go
select 1
where
"1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
go
The first "select" statement will return '1', but the second one will give
an error because sql server will consider the string as an identifier.
AMB
"DXC" wrote:
> What is the difference using the single or double quotes in a stored
> procedure ?
> Ex1: where username = @.username
> AND status = "D" -- or 'D'
> Ex2: if @.stringtype = "D" -- or 'D'
> Select ...............
>
> Thanks.
|||Thanks...........
"Alejandro Mesa" wrote:
[vbcol=seagreen]
> See "SET QUOTED_IDENTIFIER" in BOL.
> Example:
> use northwind
> go
> set quoted_identifier off
> go
> select 1
> where
> "1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
> go
> set quoted_identifier on
> go
> select 1
> where
> "1111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111" != '1'
> go
>
> The first "select" statement will return '1', but the second one will give
> an error because sql server will consider the string as an identifier.
>
> AMB
> "DXC" wrote:
Quotes
procedure ?
Ex1: where username = @.username
AND status = "D" -- or 'D'
Ex2: if @.stringtype = "D" -- or 'D'
Select ...............
Thanks.See "SET QUOTED_IDENTIFIER" in BOL.
Example:
use northwind
go
set quoted_identifier off
go
select 1
where
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
go
set quoted_identifier on
go
select 1
where
"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
go
The first "select" statement will return '1', but the second one will give
an error because sql server will consider the string as an identifier.
AMB
"DXC" wrote:
> What is the difference using the single or double quotes in a stored
> procedure ?
> Ex1: where username = @.username
> AND status = "D" -- or 'D'
> Ex2: if @.stringtype = "D" -- or 'D'
> Select ...............
>
> Thanks.|||Thanks...........
"Alejandro Mesa" wrote:
> See "SET QUOTED_IDENTIFIER" in BOL.
> Example:
> use northwind
> go
> set quoted_identifier off
> go
> select 1
> where
> "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
> go
> set quoted_identifier on
> go
> select 1
> where
> "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" != '1'
> go
>
> The first "select" statement will return '1', but the second one will give
> an error because sql server will consider the string as an identifier.
>
> AMB
> "DXC" wrote:
> > What is the difference using the single or double quotes in a stored
> > procedure ?
> >
> > Ex1: where username = @.username
> > AND status = "D" -- or 'D'
> >
> > Ex2: if @.stringtype = "D" -- or 'D'
> > Select ...............
> >
> >
> > Thanks.
Quotes
procedure ?
Ex1: where username = @.username
AND status = "D" -- or 'D'
Ex2: if @.stringtype = "D" -- or 'D'
Select ...............
Thanks.See "SET QUOTED_IDENTIFIER" in BOL.
Example:
use northwind
go
set quoted_identifier off
go
select 1
where
" 1111111111111111111111111111111111111111
11111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111" != '1'
go
set quoted_identifier on
go
select 1
where
" 1111111111111111111111111111111111111111
11111111111111111111111111111111111
1111111111111111111111111111111111111111
1111111111111" != '1'
go
The first "select" statement will return '1', but the second one will give
an error because sql server will consider the string as an identifier.
AMB
"DXC" wrote:
> What is the difference using the single or double quotes in a stored
> procedure ?
> Ex1: where username = @.username
> AND status = "D" -- or 'D'
> Ex2: if @.stringtype = "D" -- or 'D'
> Select ...............
>
> Thanks.|||Thanks...........
"Alejandro Mesa" wrote:
[vbcol=seagreen]
> See "SET QUOTED_IDENTIFIER" in BOL.
> Example:
> use northwind
> go
> set quoted_identifier off
> go
> select 1
> where
> " 1111111111111111111111111111111111111111
111111111111111111111111111111111
1111111111111111111111111111111111111111
111111111111111" != '1'
> go
> set quoted_identifier on
> go
> select 1
> where
> " 1111111111111111111111111111111111111111
111111111111111111111111111111111
1111111111111111111111111111111111111111
111111111111111" != '1'
> go
>
> The first "select" statement will return '1', but the second one will give
> an error because sql server will consider the string as an identifier.
>
> AMB
> "DXC" wrote:
>
Friday, March 9, 2012
Quick question on VB
Hey folks,
I am trying to run a batchfile or a external process ( exe ) from within a Script Task and read the process status returned by the process. Is there a sample VB script code that does this that you guys can share ? What modules do I have to Import ?
Thanks
-chiraj
This should do the trick. To test this, create a batch file in C:\temp called test.bat. Simply put "foobar" or something invalid in the batch file to create an errorlevel. Copy the code into a script task, run the package. It will show you the errorlevel in a message box.
Imports System
Imports System.Data
Imports System.Math
Imports System.Windows.Forms
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Dim stat As Integer = ExecProc("C:\\temp\\test.bat")
MessageBox.Show("The exit status was : " + stat.ToString())
Dts.TaskResult = Dts.Results.Success
End Sub
Public Function ExecProc(ByVal Path As String) As Integer
Dim objProc As System.Diagnostics.Process
Dim status As Integer
Try
objProc = New System.Diagnostics.Process()
objProc.StartInfo.FileName = Path
objProc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
objProc.Start()
'Wait until the process passes back an exit code
objProc.WaitForExit()
status = objProc.ExitCode
Catch Ex As Exception
MessageBox.Show(Ex.Message)
Finally
'Release the objProc resources
objProc.Close()
End Try
Return status
End Function
End Class
HTH,
Kirk Haselden
Author "SQL Server Integration Services"