Showing posts with label store. Show all posts
Showing posts with label store. Show all posts

Thursday, March 29, 2012

Can't store chinese in SQL Database

update Food set FoodName = ' 杏仁' where ID = 100

in database as ?

Hi SuperM,

You should use Encoding support from your .NET Application.

To Encoding:

Encoding target = Encoding.GetEncoding( "GB18030" );
Byte[] buffer = target.GetBytes( text );
return Convert.ToBase64String( buffer );

From Encoding:

Encoding target = Encoding.GetEncoding( "GB18030" );
Byte[] buffer = Convert.FromBase64String( text );
return target.GetString( buffer );

You could use GB18030 to simplified or Big5 to traditional.

Later, value converted you send to store procedure.

Good Coding!

Javier Luna
http://guydotnetxmlwebservices.blogspot.com/

|||Or set the collation settings in SQL Server. If this is SQL Server 2000, you need to run the rebuildm.exe to change the current collation settings. But this will affect other databases in your server|||

Hi bass,

"But this will affect other databases in your server".

This could be very dangerous.

Good Coding!

Javier Luna
http://guydotnetxmlwebservices.blogspot.com/

|||

SuperM wrote:

update Food set FoodName = ' 杏仁' where ID = 100

in database as ?

I would recommend defining the data column as NVarchar, NChar, or NText, when at all possible when working with non-ascii characters.

Jimmy

|||I know what you mean but that should have been a part of the planning phase so that it would be considered in the deployment. Our applications use different collation settings as they are being used in different countries. So before we even create the databases, the SQL Sever settings have been defined properly.|||

thanks,

the field needs to store chinese which must define as NVarchar, NChar, or NText

The Insert SQL as

insert into Food (FoodName) values (N'杏仁' )

The Update SQL as

update Food set FoodName = N' 杏仁' where ID = 100

Thursday, March 22, 2012

cant seem to connect to a store procedure on SQL server

Hi,

I am trying to get a page to call on a store procedure in SQL server and can seem to get it right. Any advice would be appreiated

<%@. Page Language="vb" %>
<%@. import Namespace="System.Data" %>
<%@. import Namespace="System.Data.OleDb" %>
<script runat="server"
Dim Conn as new OleDbConnection("Provider=SQLOLEDB;Server=*;Database=WEST1;User ID=*;Password=*;Trusted_Connection=False")
Sub Submit(Sender as Object, e as EventArgs)
Dim objCmd as OleDbCommand = new OleDbCommand ("vendorPending 10031,85140109", Conn)

Dim objReader as OleDbDataReader

objCmd.CommandType = CommandType.StoredProcedure

Try
objCmd.Connection.Open()
response.write ("opening data")
objReader = objCmd.ExecuteReader

catch ex as OleDbException
Response.write ("Error retrieving data.")

end try

DataGrid1.DataSource = objReader
DataGrid1.DataBind()

objCmd.Connection.Close()

End Sub

</script>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" runat="server">
<tbody>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td>
Login :
</td>
<td>
<asp:textbox id="user" runat="server"></asp:textbox>
</td>
</tr>
<tr>
<td>
Password :
</td>
<td>
<asp:textbox id="Pass" runat="server" textmode="Password" MaxLength="10"></asp:textbox>
<br />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:button id="Button1" onclick="submit" runat="server" text="submit"></asp:button>
</td>
</tr>
<br />
<tr>
<td>
</td>
</tr>
</tbody>
<br />
<asp:DataGrid id="DataGrid1" runat="server" HorizontalAlign="Left" Font-Names="Arial" ItemStyle-BackColor="#FFFFFF" AlternatingItemStyle-BackColor="#CCCCCC" Font-Size="10pt" Font-Name="Arial" width="755px" cellpadding="2" gridlins="vertical" BorderColor="Black" AutoGenerateColumns="False">
<HeaderStyle font-size="Small" font-names="Arial" font-bold="True"></HeaderStyle>
<EditItemStyle horizontalalign="Left"></EditItemStyle>
<AlternatingItemStyle backcolor="#CCCCCC"></AlternatingItemStyle>
<ItemStyle horizontalalign="Right" backcolor="White"></ItemStyle>
<Columns>
<asp:BoundColumn DataField="invnum" HeaderText="<b>Invoice Number</b>"></asp:BoundColumn>
<asp:BoundColumn DataField="invdate" HeaderText="Invoice Date" DataFormatString="{0:MM-dd-yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="duedate" HeaderText="Due Date" DataFormatString="{0:MM-dd-yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="invamt" HeaderText="Invoice Amount" DataFormatString="${0:N2}"></asp:BoundColumn>
<asp:BoundColumn DataField="payamt" HeaderText="Pay Amount" DataFormatString="${0:N2}"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>

The store proceudure takes 2 int parameters. I have coded it inline in order to test it. I also will implement validation once I get this working

Thanksuse sqlclient instead oledb. there is built in support for sql server.
heres some sample code :


Dim myCommand As SqlCommand
Dim myParam As SqlParameter
dim objcon as new sqlconnection("...") ' check www.connectionstrings.com for the right connection string
myCommand = New SqlCommand()
myCommand.Connection = objcon
myCommand.CommandText = "usp_Test"
myCommand.CommandType = CommandType.StoredProcedure

myCommand.Parameters.Add(New SqlParameter("@.userid",SqlDbType.int))
myCommand.Parameters("@.userid").Value = Trim(userid)

'add other params
dim objreader as
If objCon.State = 0 Then objCon.Open()
objreader = mycommand.ExecuteReader() ' objdatareader is your sqldatareader.
myCommand.dispose()

hth

Sunday, March 11, 2012

Can't run dts package job

I setup a job which call a dts package (I try to call it from file system and from SSIS Package Store with the same result) and it doesn't run.

If you take a look from the SQL Server Agent you could see this >>
2012-06-17 09:01:02 - ! [LOG] Step 1 of job 'prueba' (0x85B4D5E843DB3145A6A1A6A0A43D04F3) cannot be run because the DTS subsystem failed to load. The job has been suspended
Any ideas?This was happening to people that installed to a drive other than C:. Did you install to a different drive? It's a bug in setup. If so, you can fix it by changing the dbo.syssubsystems table in MSDB for the dts subsystem.

Look to see where it's pointing. It should be something like this:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\binn\SQLDTSSS90.DLL

If the drive is different then the one you installed on, correct it. It should work then.

Please let me know if this worked.
Thanks,|||I saw what you said. I installed SQL in D drive in a directory called SQL_Server. The path you told me was right but the path in the agent_exe field was wrong.

Thanks for your help.|||Excellent! Glad to help out.|||

This was a dts in SQL 2005, right? If so, how did you get to the dbo.syssubsystems table? I know its in the MSDB but I can't get access to that table, even as an admin of the box. Any ideas?

|||

Hi,

I have a similar situation. We have program files on C:\ and Data files on D:\. I ran the following sql to update the syssubsystems table, but I still get the " 2007-01-22 12:13:37 - ! [LOG] Step 1 of job 'MaintenancePlan 1' (0xC433119AFB756E4E844D94759A65B68A) cannot be run because the SSIS subsystem failed to load. The job has been suspended" message.

INSERT INTO [msdb].[dbo].[syssubsystems]

([subsystem_id]

,[subsystem]

,[description_id]

,[subsystem_dll]

,[agent_exe]

,[start_entry_point]

,[event_entry_point]

,[stop_entry_point]

,[max_worker_threads])

VALUES

(11

,'SSIS'

,14538

,'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\binn\SQLDTSSS90.DLL'

,'C:\Program Files\Microsoft SQL Server\90\DTS\Connections\Binn\DTExec.exe'

,'DtsStart'

,'DtsEvent'

,'DtsStop'

,200);

Do I need to restart the Intergration services service?

Paul

|||

janislkovach wrote:

This was a dts in SQL 2005, right? If so, how did you get to the dbo.syssubsystems table? I know its in the MSDB but I can't get access to that table, even as an admin of the box. Any ideas?

Did you log in as a SQL Server admin?|||

Yes I can login to the box with Domain admin, then onto the Database engine with the SA id and password. I run the sqlagent job as a 'SQL Server Intergration Services package' and it fails with the 'failed to load susbsystem message'. If I run it as an 'Operating system(CmdExec)' i.e dtexec / SQL "[package name]" etc, then it works.

I can obviously get round the problem this way, but it's frustrating it doesn't work as it should. I think it started to happen after SP1 was installed.

Is it something to do with what account Integration Services runs under? As all the other SQL server service run as domain admin, my intergration Services service runs as NT authority\network service. Should I run this as domain admin also?

One further thing, when comparing other boxes with my problem box, is that I have DTEXEC.exe & DTAttach(and associated Dll's) in C:\Program Files\Microsoft SQL Server\90\DTS\Connections\Binn on the problem box whereas they are in C:\Program Files\Microsoft SQL Server\90\DTS\Binn in all other ones. Is this my problem? Can I simply move them to C:\Program Files\Microsoft SQL Server\90\DTS\Binn?

Can't run dts package job

I setup a job which call a dts package (I try to call it from file system and from SSIS Package Store with the same result) and it doesn't run.

If you take a look from the SQL Server Agent you could see this >>
2012-06-17 09:01:02 - ! [LOG] Step 1 of job 'prueba' (0x85B4D5E843DB3145A6A1A6A0A43D04F3) cannot be run because the DTS subsystem failed to load. The job has been suspended
Any ideas?This was happening to people that installed to a drive other than C:. Did you install to a different drive? It's a bug in setup. If so, you can fix it by changing the dbo.syssubsystems table in MSDB for the dts subsystem.

Look to see where it's pointing. It should be something like this:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\binn\SQLDTSSS90.DLL

If the drive is different then the one you installed on, correct it. It should work then.

Please let me know if this worked.
Thanks,|||I saw what you said. I installed SQL in D drive in a directory called SQL_Server. The path you told me was right but the path in the agent_exe field was wrong.

Thanks for your help.|||Excellent! Glad to help out.|||

This was a dts in SQL 2005, right? If so, how did you get to the dbo.syssubsystems table? I know its in the MSDB but I can't get access to that table, even as an admin of the box. Any ideas?

|||

Hi,

I have a similar situation. We have program files on C:\ and Data files on D:\. I ran the following sql to update the syssubsystems table, but I still get the " 2007-01-22 12:13:37 - ! [LOG] Step 1 of job 'MaintenancePlan 1' (0xC433119AFB756E4E844D94759A65B68A) cannot be run because the SSIS subsystem failed to load. The job has been suspended" message.

INSERT INTO [msdb].[dbo].[syssubsystems]

([subsystem_id]

,[subsystem]

,[description_id]

,[subsystem_dll]

,[agent_exe]

,[start_entry_point]

,[event_entry_point]

,[stop_entry_point]

,[max_worker_threads])

VALUES

(11

,'SSIS'

,14538

,'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\binn\SQLDTSSS90.DLL'

,'C:\Program Files\Microsoft SQL Server\90\DTS\Connections\Binn\DTExec.exe'

,'DtsStart'

,'DtsEvent'

,'DtsStop'

,200);

Do I need to restart the Intergration services service?

Paul

|||

janislkovach wrote:

This was a dts in SQL 2005, right? If so, how did you get to the dbo.syssubsystems table? I know its in the MSDB but I can't get access to that table, even as an admin of the box. Any ideas?

Did you log in as a SQL Server admin?|||

Yes I can login to the box with Domain admin, then onto the Database engine with the SA id and password. I run the sqlagent job as a 'SQL Server Intergration Services package' and it fails with the 'failed to load susbsystem message'. If I run it as an 'Operating system(CmdExec)' i.e dtexec / SQL "[package name]" etc, then it works.

I can obviously get round the problem this way, but it's frustrating it doesn't work as it should. I think it started to happen after SP1 was installed.

Is it something to do with what account Integration Services runs under? As all the other SQL server service run as domain admin, my intergration Services service runs as NT authority\network service. Should I run this as domain admin also?

One further thing, when comparing other boxes with my problem box, is that I have DTEXEC.exe & DTAttach(and associated Dll's) in C:\Program Files\Microsoft SQL Server\90\DTS\Connections\Binn on the problem box whereas they are in C:\Program Files\Microsoft SQL Server\90\DTS\Binn in all other ones. Is this my problem? Can I simply move them to C:\Program Files\Microsoft SQL Server\90\DTS\Binn?

Can't run dts package job

I setup a job which call a dts package (I try to call it from file system and from SSIS Package Store with the same result) and it doesn't run.

If you take a look from the SQL Server Agent you could see this >>
2012-06-17 09:01:02 - ! [LOG] Step 1 of job 'prueba' (0x85B4D5E843DB3145A6A1A6A0A43D04F3) cannot be run because the DTS subsystem failed to load. The job has been suspended
Any ideas?This was happening to people that installed to a drive other than C:. Did you install to a different drive? It's a bug in setup. If so, you can fix it by changing the dbo.syssubsystems table in MSDB for the dts subsystem.

Look to see where it's pointing. It should be something like this:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\binn\SQLDTSSS90.DLL

If the drive is different then the one you installed on, correct it. It should work then.

Please let me know if this worked.
Thanks,|||I saw what you said. I installed SQL in D drive in a directory called SQL_Server. The path you told me was right but the path in the agent_exe field was wrong.

Thanks for your help.|||Excellent! Glad to help out.|||

This was a dts in SQL 2005, right? If so, how did you get to the dbo.syssubsystems table? I know its in the MSDB but I can't get access to that table, even as an admin of the box. Any ideas?

|||

Hi,

I have a similar situation. We have program files on C:\ and Data files on D:\. I ran the following sql to update the syssubsystems table, but I still get the " 2007-01-22 12:13:37 - ! [LOG] Step 1 of job 'MaintenancePlan 1' (0xC433119AFB756E4E844D94759A65B68A) cannot be run because the SSIS subsystem failed to load. The job has been suspended" message.

INSERT INTO [msdb].[dbo].[syssubsystems]

([subsystem_id]

,[subsystem]

,[description_id]

,[subsystem_dll]

,[agent_exe]

,[start_entry_point]

,[event_entry_point]

,[stop_entry_point]

,[max_worker_threads])

VALUES

(11

,'SSIS'

,14538

,'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\binn\SQLDTSSS90.DLL'

,'C:\Program Files\Microsoft SQL Server\90\DTS\Connections\Binn\DTExec.exe'

,'DtsStart'

,'DtsEvent'

,'DtsStop'

,200);

Do I need to restart the Intergration services service?

Paul

|||

janislkovach wrote:

This was a dts in SQL 2005, right? If so, how did you get to the dbo.syssubsystems table? I know its in the MSDB but I can't get access to that table, even as an admin of the box. Any ideas?

Did you log in as a SQL Server admin?|||

Yes I can login to the box with Domain admin, then onto the Database engine with the SA id and password. I run the sqlagent job as a 'SQL Server Intergration Services package' and it fails with the 'failed to load susbsystem message'. If I run it as an 'Operating system(CmdExec)' i.e dtexec / SQL "[package name]" etc, then it works.

I can obviously get round the problem this way, but it's frustrating it doesn't work as it should. I think it started to happen after SP1 was installed.

Is it something to do with what account Integration Services runs under? As all the other SQL server service run as domain admin, my intergration Services service runs as NT authority\network service. Should I run this as domain admin also?

One further thing, when comparing other boxes with my problem box, is that I have DTEXEC.exe & DTAttach(and associated Dll's) in C:\Program Files\Microsoft SQL Server\90\DTS\Connections\Binn on the problem box whereas they are in C:\Program Files\Microsoft SQL Server\90\DTS\Binn in all other ones. Is this my problem? Can I simply move them to C:\Program Files\Microsoft SQL Server\90\DTS\Binn?

Sunday, February 12, 2012

can''t import views and store procedures

I recently set up a new sql 2005 standard edition and planning to mirgrate our production sql 2000 data. but only the tables were migrated from the copy data or import / export task. I cannot find a way to recreate the store procedures and views on the new server without create one view and one store procedure at a time unless all hundreds of views and procedures were rescripted. can anyone help

Thank

Andy Wong

awong@.virginiadare.com

Right click the database > Taks > Generate Scripts, this will give you the option to put it in one output-file

Jens K. Suessmeyer

http://www.sqlserver2005.de