sql-server-2008

I need to import data from Excel to SQL Server using VBA

回眸只為那壹抹淺笑 提交于 2021-02-08 05:48:17
问题 I am trying to import data from another Excel workbook on my PC into SQL Server. I tried with this code, but it doesn't work: Sub insertion() Dim conn As ADODB.Connection Dim rs As ADODB.Recordset Dim sConnString As String Dim rsstring As String Dim m, nrows As Integer Dim loRH As Excel.ListObject Workbooks("test-vba.xls").Activate *connection* Set conn = New ADODB.Connection Set rs = New ADODB.Recordset conn.Open sConnString MsgBox "Start" Set loRH = wkb.ListObjects(1) loRH.ListColumns(1)

Transferring Data by SMO failing when using ObjectList

时光怂恿深爱的人放手 提交于 2021-02-07 19:53:15
问题 I can transfer all data from a source DB to a target DB by using the option CopyAllTables = true and not providing a list in ObjectList. ServerConnection conn = new ServerConnection(sourceServer); conn.LoginSecure = true; Server srvSource = new Server(conn); Database dbSource = srvSource.Databases[sourceDB]; Transfer xfr = new Transfer(dbSource); xfr.CopyAllTables = true; xfr.Options.WithDependencies = false; xfr.Options.ContinueScriptingOnError = false; xfr.DestinationDatabase = destDB; xfr

Get ID of Last Inserted Record - Access DAO, ODBC, SQL Server 2008 Identity Field

三世轮回 提交于 2021-02-07 19:46:00
问题 It's a very common question but I'm having trouble getting the ID of the last inserted record. I'm using DAO with ODBC linked tables to duplicate a record and it's child records. My tables are in SQL Server 2008 and have Identity fields for ID fields. Here's what I've tried so far. My first bit of code here results in error 3167, Record is Deleted. If I do a debug.Print the recordset actually contains 3 records. Dim r as DAO.Recordset, db as DAO.Database Set db = CurrentDb Set r = db

Get ID of Last Inserted Record - Access DAO, ODBC, SQL Server 2008 Identity Field

安稳与你 提交于 2021-02-07 19:45:06
问题 It's a very common question but I'm having trouble getting the ID of the last inserted record. I'm using DAO with ODBC linked tables to duplicate a record and it's child records. My tables are in SQL Server 2008 and have Identity fields for ID fields. Here's what I've tried so far. My first bit of code here results in error 3167, Record is Deleted. If I do a debug.Print the recordset actually contains 3 records. Dim r as DAO.Recordset, db as DAO.Database Set db = CurrentDb Set r = db

How to query against multiple linked servers?

若如初见. 提交于 2021-02-07 18:23:30
问题 After linking some SQL Server 2008 Servers / instances, I would like to do a more generic query against these servers. I know that I must specify the destiny of the query like that: select * from [SRV\INSTANCE].dbname.dbo.foo But, I would run this query against more than one linked server. I know also that this select statement returns exactly the SRV\INSTANCE that I need: select ss.name from sys.servers ss where ss.server_id > 0 This one, returns all servers\instances from where I want query

How to query against multiple linked servers?

一世执手 提交于 2021-02-07 18:23:25
问题 After linking some SQL Server 2008 Servers / instances, I would like to do a more generic query against these servers. I know that I must specify the destiny of the query like that: select * from [SRV\INSTANCE].dbname.dbo.foo But, I would run this query against more than one linked server. I know also that this select statement returns exactly the SRV\INSTANCE that I need: select ss.name from sys.servers ss where ss.server_id > 0 This one, returns all servers\instances from where I want query

Find columns that contain only zeros

有些话、适合烂在心里 提交于 2021-02-07 14:18:27
问题 I'm working with SQL Server 2008. I have a list of column names on a table and I'd like to know how to use SQL to return the names of those columns which contain nothing but zero or NULL values. 回答1: declare @T table ( Col1 int, Col2 int, Col3 int, Col4 int ) insert into @T values (1, 0 , null, null), (0, null, 0 , 1) select U.ColName from ( select count(nullif(Col1, 0)) as Col1, count(nullif(Col2, 0)) as Col2, count(nullif(Col3, 0)) as Col3, count(nullif(Col4, 0)) as Col4 from @T ) as T

how to change isolation level?

时光怂恿深爱的人放手 提交于 2021-02-07 14:13:57
问题 I am using EF 4.0, and I would like to use the isolation level serializable , because in a transaction I would like to block a register when is read. Well, in SQL Server I try to change the isolation level with this command: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; And in C# I use this code to try to block the register: using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.Serializable })) {

How to set SSRS ConsumeContainerWhitespace property in Visual Studio 2008?

╄→尐↘猪︶ㄣ 提交于 2021-02-07 11:28:33
问题 I am trying to set ConsumeContainerWhitespace using the Report Designer in Visual Studio 2008, but I can't find the property in the GUI. Since I can't find it, I'm wondering if this is new to VS 2010. Is it possible to set this property in VS 2008? If so, how is it done? 回答1: You can set this property using the VS2008 GUI. Just click on the report surface and hit F4 to bring up the properties window, and then select "Report" in the object selector at the top of the window. You should then see

What is the best way to allow a user to add columns to their database on-the-fly? [closed]

拥有回忆 提交于 2021-02-07 08:08:26
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question We're looking at designing an application for managing contact information. One of the customer's requests is to allow their powerusers or admin-type staff to add columns to the database through the UI. Customers do not have direct access to the database