Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Tuesday, March 27, 2012

Best SQL IDE

Anyone have any thoughts on the best IDE for SQL Server development? I'd
like object explorer, drag-and-drop, code formatting, code completion, code
analysis, execution, query builder, the WORKS! I've tried RapidSQL, having
gotten excited by their online demo, but I have not found it well-behaved.
It completely crashed no less than 5 times in as many minutes. D'oh!
TIA!
RobertPersonally, I like Management Studio (SQL Server 2005) with PromptSQL (which
gives you IntelliSense in SSMS, Query Analyzer, etc). I'm pretty religious
about code formatting, and I have no need for a "query builder" (especially
those with bugs or really nasty side effects).
"Best" is going to be pretty subjective, since everyone has their own
opinions, criteria, etc. Like what is the best car, I can't even count how
many variables go into that, and why you get as many answers as there are
people.
A
"Robert Davis" <radbase@.yahoo.com> wrote in message
news:eP5T2VIwFHA.724@.TK2MSFTNGP14.phx.gbl...
> Anyone have any thoughts on the best IDE for SQL Server development? I'd
> like object explorer, drag-and-drop, code formatting, code completion,
> code analysis, execution, query builder, the WORKS! I've tried RapidSQL,
> having gotten excited by their online demo, but I have not found it
> well-behaved. It completely crashed no less than 5 times in as many
> minutes. D'oh!
> TIA!
> Robert
>|||I havn't had time to try this out myself, but there is a 3rd party tool for
enabled T-SQL intellisense style code completion. It claims to work with
Query Analyzer, VS 2003 and 2005 Enterprise Manager.
http://www.promptsql.com/
I don't know about formatting. I have my own style of structured indenting
and comes so natural I don't even think about it when typing.
"Robert Davis" <radbase@.yahoo.com> wrote in message
news:eP5T2VIwFHA.724@.TK2MSFTNGP14.phx.gbl...
> Anyone have any thoughts on the best IDE for SQL Server development? I'd
> like object explorer, drag-and-drop, code formatting, code completion,
> code analysis, execution, query builder, the WORKS! I've tried RapidSQL,
> having gotten excited by their online demo, but I have not found it
> well-behaved. It completely crashed no less than 5 times in as many
> minutes. D'oh!
> TIA!
> Robert
>|||Hi
You may want to look through the Readers choices in the September SQL Server
Magazine
http://www.windowsitpro.com/SQLServ.../786/Index.html
John
"Robert Davis" <radbase@.yahoo.com> wrote in message
news:eP5T2VIwFHA.724@.TK2MSFTNGP14.phx.gbl...
> Anyone have any thoughts on the best IDE for SQL Server development? I'd
> like object explorer, drag-and-drop, code formatting, code completion,
> code analysis, execution, query builder, the WORKS! I've tried RapidSQL,
> having gotten excited by their online demo, but I have not found it
> well-behaved. It completely crashed no less than 5 times in as many
> minutes. D'oh!
> TIA!
> Robert
>|||I've had good success with ApexSQLEdit - has intellsense, execution
plans [not as graphic as SQL Q/A - i.e., in a flowchart view, but not
with icons for ss, scans, etc., but has the text to explain it], and
integration with source control.
www.apexsql.com
They have other good tools as well.
Robert Davis wrote:

>Anyone have any thoughts on the best IDE for SQL Server development? I'd
>like object explorer, drag-and-drop, code formatting, code completion, code
>analysis, execution, query builder, the WORKS! I've tried RapidSQL, having
>gotten excited by their online demo, but I have not found it well-behaved.
>It completely crashed no less than 5 times in as many minutes. D'oh!
>TIA!
>Robert
>
>|||Here is another query builder to keep an eye on:
http://151.100.3.84/technicalpreview/
Pamela

Thursday, March 8, 2012

Best Practice Analyzer scan

I have a scan that is returning an exception.
The exception is on a trigger.
The trigger does an insert and refers to another object and I don't
have the object prefixed with a user/schema within the trigger. My
application is deliveried as static ddl and the customer chooses what
user (2000) or schema (2005) to install it into. How can I code the
trigger to include the user/schema name when it can be different for
each customer?
Here's the scan - One or more objects are refencing tables/views
without specifying a schema! Performance and predictability of the
application may be improved by specifying schema names.
Can you use suser_name to give the login id and go from there?
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"dunleav1" <jmd@.dunleavyenterprises.com> wrote in message
news:1161344508.902991.253770@.m73g2000cwd.googlegr oups.com...
>I have a scan that is returning an exception.
> The exception is on a trigger.
> The trigger does an insert and refers to another object and I don't
> have the object prefixed with a user/schema within the trigger. My
> application is deliveried as static ddl and the customer chooses what
> user (2000) or schema (2005) to install it into. How can I code the
> trigger to include the user/schema name when it can be different for
> each customer?
> Here's the scan - One or more objects are refencing tables/views
> without specifying a schema! Performance and predictability of the
> application may be improved by specifying schema names.
>

Best Practice Analyzer scan

I have a scan that is returning an exception.
The exception is on a trigger.
The trigger does an insert and refers to another object and I don't
have the object prefixed with a user/schema within the trigger. My
application is deliveried as static ddl and the customer chooses what
user (2000) or schema (2005) to install it into. How can I code the
trigger to include the user/schema name when it can be different for
each customer?
Here's the scan - One or more objects are refencing tables/views
without specifying a schema! Performance and predictability of the
application may be improved by specifying schema names.Can you use suser_name to give the login id and go from there?
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"dunleav1" <jmd@.dunleavyenterprises.com> wrote in message
news:1161344508.902991.253770@.m73g2000cwd.googlegroups.com...
>I have a scan that is returning an exception.
> The exception is on a trigger.
> The trigger does an insert and refers to another object and I don't
> have the object prefixed with a user/schema within the trigger. My
> application is deliveried as static ddl and the customer chooses what
> user (2000) or schema (2005) to install it into. How can I code the
> trigger to include the user/schema name when it can be different for
> each customer?
> Here's the scan - One or more objects are refencing tables/views
> without specifying a schema! Performance and predictability of the
> application may be improved by specifying schema names.
>

Best Practice Analyzer scan

I have a scan that is returning an exception.
The exception is on a trigger.
The trigger does an insert and refers to another object and I don't
have the object prefixed with a user/schema within the trigger. My
application is deliveried as static ddl and the customer chooses what
user (2000) or schema (2005) to install it into. How can I code the
trigger to include the user/schema name when it can be different for
each customer?
Here's the scan - One or more objects are refencing tables/views
without specifying a schema! Performance and predictability of the
application may be improved by specifying schema names.Can you use suser_name to give the login id and go from there?
--
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"dunleav1" <jmd@.dunleavyenterprises.com> wrote in message
news:1161344508.902991.253770@.m73g2000cwd.googlegroups.com...
>I have a scan that is returning an exception.
> The exception is on a trigger.
> The trigger does an insert and refers to another object and I don't
> have the object prefixed with a user/schema within the trigger. My
> application is deliveried as static ddl and the customer chooses what
> user (2000) or schema (2005) to install it into. How can I code the
> trigger to include the user/schema name when it can be different for
> each customer?
> Here's the scan - One or more objects are refencing tables/views
> without specifying a schema! Performance and predictability of the
> application may be improved by specifying schema names.
>

Friday, February 10, 2012

BDNull error...not expected!

I have a connection (SqlConnection1) established through the GUI. Here's the
code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Create and initialise the command object
Dim cmd As New SqlCommand("GetAddress", SqlConnection1)
'State that the type of this command is a stored procedure
cmd.CommandType = CommandType.StoredProcedure
'Create the input paramater
cmd.Parameters.Add("@.BizName", SqlDbType.VarChar, 50)
cmd.Parameters("@.BizName").Direction = ParameterDirection.Input
cmd.Parameters("@.BizName").Value = TextBox1.Text
'Create the output paramater
cmd.Parameters.Add("@.BizAddress", SqlDbType.VarChar, 50)
cmd.Parameters("@.BizAddress").Direction = ParameterDirection.Output
'Enusre the connection is open
If (cmd.Connection.State <> ConnectionState.Open) Then
cmd.Connection.Open()
End If
'Execute the command object
cmd.ExecuteNonQuery()
'Assign the returned value of the output paramater
TextBox2.Text = cmd.Parameters("@.BizAddress").Value
'Close the connection
cmd.Connection.Close()
End Sub
This code allows a textbox (textbox1) to fill an input paramater and
displays the contents of the returned value from the output paramater in a
textbox (textbox2). It works fine with s imple select statement. But with a
stored procedure i get this error:
Cast from type 'DBNull' to type 'String' is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.InvalidCastException: Cast from type 'DBNull' to
type 'String' is not valid.
Source Error:
Line 63:
Line 64: 'Assign the returned value of the output paramater
Line 65: TextBox2.Text = cmd.Parameters("@.BizAddress").Value
The code for the stored procedure:
CREATE PROCEDURE GetAddress
@.BizName varchar,
@.BizAddress varchar output
AS
SELECT @.BizAddress = Address FROM nabilTable WHERE Name = @.BizName
GO
Where did i go wrong?
Thanks for any insights.
NabYour Stored Procedure is returning a NULL value in the @.BizAddress output
parameter. You need to assign the value to an Object and check it for
DBNull.value before converting to string:
Dim o As Object
o = cmd.Parameters("@.BizAddress").Value
If (o Is Nothing OrElse o Is DBNull.Value) Then
TextBox2.Text = ""
Else
TextBox2.Text = Convert.ToString(o)
EndIf
"Nab" <Nab@.discussions.microsoft.com> wrote in message
news:96300218-F090-44B3-A5E9-F30FCE80D711@.microsoft.com...
>I have a connection (SqlConnection1) established through the GUI. Here's
>the
> code:
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> 'Create and initialise the command object
> Dim cmd As New SqlCommand("GetAddress", SqlConnection1)
> 'State that the type of this command is a stored procedure
> cmd.CommandType = CommandType.StoredProcedure
> 'Create the input paramater
> cmd.Parameters.Add("@.BizName", SqlDbType.VarChar, 50)
> cmd.Parameters("@.BizName").Direction = ParameterDirection.Input
> cmd.Parameters("@.BizName").Value = TextBox1.Text
> 'Create the output paramater
> cmd.Parameters.Add("@.BizAddress", SqlDbType.VarChar, 50)
> cmd.Parameters("@.BizAddress").Direction = ParameterDirection.Output
> 'Enusre the connection is open
> If (cmd.Connection.State <> ConnectionState.Open) Then
> cmd.Connection.Open()
> End If
> 'Execute the command object
> cmd.ExecuteNonQuery()
> 'Assign the returned value of the output paramater
> TextBox2.Text = cmd.Parameters("@.BizAddress").Value
> 'Close the connection
> cmd.Connection.Close()
> End Sub
> This code allows a textbox (textbox1) to fill an input paramater and
> displays the contents of the returned value from the output paramater in a
> textbox (textbox2). It works fine with s imple select statement. But with
> a
> stored procedure i get this error:
> Cast from type 'DBNull' to type 'String' is not valid.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
> Exception Details: System.InvalidCastException: Cast from type 'DBNull' to
> type 'String' is not valid.
> Source Error:
>
> Line 63:
> Line 64: 'Assign the returned value of the output paramater
> Line 65: TextBox2.Text = cmd.Parameters("@.BizAddress").Value
>
> The code for the stored procedure:
> CREATE PROCEDURE GetAddress
> @.BizName varchar,
> @.BizAddress varchar output
> AS
> SELECT @.BizAddress = Address FROM nabilTable WHERE Name = @.BizName
> GO
> Where did i go wrong?
> Thanks for any insights.
> Nab
>
>|||A NULL @.BizAddress value will be returned when no data is found and this
cannot be converted to a .Net string data type. You can check for NULL
using DbNull.Value:
If cmd.Parameters("@.BizAddress").Value Is DBNull.Value Then
MessageBox.Show("BizName not found")
Else
TextBox2.Text = cmd.Parameters("@.BizAddress").Value
End If
Also, you need specify varchar(50) in your stored procedure parameter
declaration. The default length is 1.
CREATE PROCEDURE GetAddress
@.BizName varchar(50),
@.BizAddress varchar (50) output
AS
SELECT @.BizAddress = Address FROM nabilTable WHERE Name = @.BizName
GO
Hope this helps.
Dan Guzman
SQL Server MVP
"Nab" <Nab@.discussions.microsoft.com> wrote in message
news:96300218-F090-44B3-A5E9-F30FCE80D711@.microsoft.com...
>I have a connection (SqlConnection1) established through the GUI. Here's
>the
> code:
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> 'Create and initialise the command object
> Dim cmd As New SqlCommand("GetAddress", SqlConnection1)
> 'State that the type of this command is a stored procedure
> cmd.CommandType = CommandType.StoredProcedure
> 'Create the input paramater
> cmd.Parameters.Add("@.BizName", SqlDbType.VarChar, 50)
> cmd.Parameters("@.BizName").Direction = ParameterDirection.Input
> cmd.Parameters("@.BizName").Value = TextBox1.Text
> 'Create the output paramater
> cmd.Parameters.Add("@.BizAddress", SqlDbType.VarChar, 50)
> cmd.Parameters("@.BizAddress").Direction = ParameterDirection.Output
> 'Enusre the connection is open
> If (cmd.Connection.State <> ConnectionState.Open) Then
> cmd.Connection.Open()
> End If
> 'Execute the command object
> cmd.ExecuteNonQuery()
> 'Assign the returned value of the output paramater
> TextBox2.Text = cmd.Parameters("@.BizAddress").Value
> 'Close the connection
> cmd.Connection.Close()
> End Sub
> This code allows a textbox (textbox1) to fill an input paramater and
> displays the contents of the returned value from the output paramater in a
> textbox (textbox2). It works fine with s imple select statement. But with
> a
> stored procedure i get this error:
> Cast from type 'DBNull' to type 'String' is not valid.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
> Exception Details: System.InvalidCastException: Cast from type 'DBNull' to
> type 'String' is not valid.
> Source Error:
>
> Line 63:
> Line 64: 'Assign the returned value of the output paramater
> Line 65: TextBox2.Text = cmd.Parameters("@.BizAddress").Value
>
> The code for the stored procedure:
> CREATE PROCEDURE GetAddress
> @.BizName varchar,
> @.BizAddress varchar output
> AS
> SELECT @.BizAddress = Address FROM nabilTable WHERE Name = @.BizName
> GO
> Where did i go wrong?
> Thanks for any insights.
> Nab
>
>|||Nab wrote:
> I have a connection (SqlConnection1) established through the GUI.
> Here's the code:
>
You really should post these client-side questions to a more appropriate
newsgroup. Here are some suggestions:
microsoft.public.dotnet.languages.vb.data
microsoft.public.dotnet.framework.adonet
More below:

> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> 'Create and initialise the command object
> Dim cmd As New SqlCommand("GetAddress", SqlConnection1)
> 'State that the type of this command is a stored procedure
> cmd.CommandType = CommandType.StoredProcedure
> 'Create the input paramater
> cmd.Parameters.Add("@.BizName", SqlDbType.VarChar, 50)
> cmd.Parameters("@.BizName").Direction = ParameterDirection.Input
> cmd.Parameters("@.BizName").Value = TextBox1.Text
> 'Create the output paramater
> cmd.Parameters.Add("@.BizAddress", SqlDbType.VarChar, 50)
> cmd.Parameters("@.BizAddress").Direction =
> ParameterDirection.Output
>
<snip>
> 'Execute the command object
> cmd.ExecuteNonQuery()
> 'Assign the returned value of the output paramater
> TextBox2.Text = cmd.Parameters("@.BizAddress").Value
>
<snip>
> Exception Details: System.InvalidCastException: Cast from type
> 'DBNull' to type 'String' is not valid.
>
<snip>
> The code for the stored procedure:
> CREATE PROCEDURE GetAddress
> @.BizName varchar,
> @.BizAddress varchar output
Always, always, ALWAYS set the length of your parameters:
@.BizName varchar(50),
@.BizAddress varchar(50) output
Do not depend on the default values,

> AS
> SELECT @.BizAddress = Address FROM nabilTable WHERE Name = @.BizName
> GO
>
From online help:
If the ParameterDirection is output, and execution of the associated
SqlCommand does not return a value, the SqlParameter contains a null value.
So I would guess that the value of @.BizName is not getting set. Use SQL
Profiler to verify this.
Bob Barrows
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"|||Thanks Dan. Stating the size in the stored procedure did the trick. Cheers.
Nab
"Dan Guzman" wrote:

> A NULL @.BizAddress value will be returned when no data is found and this
> cannot be converted to a .Net string data type. You can check for NULL
> using DbNull.Value:
> If cmd.Parameters("@.BizAddress").Value Is DBNull.Value Then
> MessageBox.Show("BizName not found")
> Else
> TextBox2.Text = cmd.Parameters("@.BizAddress").Value
> End If
> Also, you need specify varchar(50) in your stored procedure parameter
> declaration. The default length is 1.
> CREATE PROCEDURE GetAddress
> @.BizName varchar(50),
> @.BizAddress varchar (50) output
> AS
> SELECT @.BizAddress = Address FROM nabilTable WHERE Name = @.BizName
> GO
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Nab" <Nab@.discussions.microsoft.com> wrote in message
> news:96300218-F090-44B3-A5E9-F30FCE80D711@.microsoft.com...
>
>