-
WSsal21
AskWoody LoungerSQL Manager in the server or from a PC. You can then choose the fields you require.
Copy the output into Excel and save as CSV.cheers, Paul
no SQL Manager only code vb6 or vba for excel
-
WSsal21
AskWoody LoungerDo you need to copy the table or just the data? ie does the table already exist in the second database?
– table and the data
To copy the data you can use two ADO connections.
Moving through the recordset in the first database and appending it to the second.
To create the table itself, if you need to, then do you want to do this in code as well or manually.
Manually – in Management Studio, right click on the table, select Script Table As > Create To > New Query Editor WIndow.
This will create a query for you to run on the second database to create the same table structure.
Or if you want to create the table in the second database using code then you can use the query you just created to build DDL code that you can run against your ADO connection.
So to answer your question, we really need to know more about what you need to do and how much you already know
eg how much do you know about using ADO recordsets?
Can you create the tables in Management Studio? If not then are you familiar with DDL?
– no
– no -
WSsal21
AskWoody LoungerCould try this
Function top and then just an example of using it in a sub below
Note it also works on a sheet as a function
Code:Function FindDateDiffDays(varStart, varEnd) As Long Dim lngDiff As Long, dteStart As Date, dteEnd As Date 'NOTE there is NO error trapping in this Application.Volatile dteStart = DateSerial(Left(varStart, 4), Mid(varStart, 5, 2), Right(varStart, 2)) dteEnd = DateSerial(Left(varEnd, 4), Mid(varEnd, 5, 2), Right(varEnd, 2)) lngDiff = (dteEnd - dteStart) + 1 FindDateDiffDays = lngDiff End Function Sub ExampleDD() Dim varStart, varEnd, lngDays As Long varStart = 20100405 varEnd = 20100409 lngDays = FindDateDiffDays(varStart, varEnd) MsgBox "Difference is.... " & lngDays End Sub
NATURALLY WORK!
Tks. -
WSsal21
AskWoody LoungerI am sure there are several solutions to this
Here is a sub with an example
You could make it into a Function and pass the Date
Code:Sub CheckDate() Dim varDate, varRealDate, strDay As String varDate = "20100405" varRealDate = DateSerial(Left(varDate, 4), Mid(varDate, 5, 2), Right(varDate, 2)) strDay = Format(varRealDate, "ddd") 'You may need to change this to use the Local Language equivalent of Monday If strDay = "Mon" Then MsgBox "Monday" Else MsgBox "Not a Monday " & strDay End If End Sub
OR as a Function that returns True or False
Code:Function CheckMonday(varDate) As Boolean Dim varRealDate, strDay As String Application.Volatile varRealDate = DateSerial(Left(varDate, 4), Mid(varDate, 5, 2), Right(varDate, 2)) strDay = Format(varRealDate, "ddd") 'You may need to change this to use the Local Language equivalent of Monday If strDay = "Mon" Then CheckMonday = True Else CheckMonday = False End If End Function
work perfect!
sorry but how to calculate datediff in days between 20100405 and 20100409 …in this case is 5
Tks. -
WSsal21
AskWoody LoungerGenerally, you want to use the NoMatch property after you do a Find; that is: If rs1.NoMatch = False then …
error: member or method not fiund
in line rs.NoMatch -
WSsal21
AskWoody LoungerAh.. But you didn’t say that.
Yes it does
In that case you probably need to open the recordset outside of the loop
Code:'Outside your Loop set rst=New ADODB.Recordset strSQL="SELECT * FROM tblTest " rst.Open strSQL,conn, adOpenStatic, adLockReadOnly 'Then inside your loop after var is set rst.Movefirst strWhere = "[Test]='" & var & "'" rst.Find strWhere If rst.EOF Then Var_Finded="No Matching Entry Found" Else Var_Finded=rst![Test1] End If 'Whatever else you want to do 'End of Your Loop rst.Close set rst=Nothing
This opens the Recordset Up Once with all records and uses the FIND Method to Look for the Specific Record
It is important each time through the loop to set the Record Pointer Back to the First Recordsimilar:
‘Outside your Loop
set rst=New ADODB.Recordset
strSQL=”SELECT * FROM tblTest ”
rst.Open strSQL,conn, adOpenStatic, adLockReadOnly‘Then inside your loop after var is set
for each cells in my range
var = cells….rst.Movefirst
strWhere = “[Test]='” & var & “‘”
rst.Find strWhere
If rst.EOF Then
Var_Finded=”No Matching Entry Found”
Else
Var_Finded=rst![Test1]
End If‘Whatever else you want to do
‘End of Your Loop
next cells
rst.Close
set rst=Nothing -
WSsal21
AskWoody LoungerI assume that this is NOT running from Access in which case DLOOKUP is not available to you.
so you will need to reference a table eg tblTest via an ADO Recordset[/size][/size][/font]
Something Like this ought to work.[/size]
[/size][/font]
[Code]
set rst=New ADODB.Recordset
strSQL=”SELECT * FROM tblTest WHERE [Test]='” & var & “‘”
rst.Open strSQL,conn, adOpenStatic, adLockReadOnly
If Not rst.EOF Then
Var_Finded=rst![Test1]
Else
Var_Finded=”No Matching Entry Found”
End If
rst.Close
Set rst=Nothing
[/Code]ok… tks for code.
But the var is dinamic…. i fill var from a loop in range in Excel colum.
If i use your code is required to open and closed recordset each time, or not? -
WSsal21
AskWoody LoungerPlace the following declaration at the top of the code module:
Code:Public Declare Function SetCurrentDirectory _ Lib "kernel32" Alias "SetCurrentDirectoryA" _ (ByVal lpPathName As String) As Long
You can now use
Code:Dim Vfile SetCurrentDirectory "\myserverdir1dir2" Vfile = Application.GetOpenFilename("CSV files,*.csv")
… but instead to open dialogbox, i know the name of file, how to set Vfile?
-
WSsal21
AskWoody LoungerFor example:
Code:Dim DATA_TIPOLOGIA As String DATA_TIPOLOGIA = "06/01/2010" DATA_TIPOLOGIA = DateAdd("m", -1, DateValue(DATA_TIPOLOGIA)) MsgBox DATA_TIPOLOGIA
work! tks.
-
WSsal21
AskWoody Loungersorry for some reason i’m missing a blank between the quotes in my fragment – each of the function calls ‘InStr(strTemp, ” “)’ should have 2 blanks between the quotes, not 1….. if there’s only 1, all spaces will be removed.
:-/
Tks to thr all…!!!
Resolaved with one or more solution in this post. -
WSsal21
AskWoody LoungerYou can use:
Code:My_Var = Application.Trim(My_Var)
… but if i am not wrong, the line code delete all blank space, or not?
In effect i want to reduce the number of blank space in one only.
example:
if the string contain 4 balnk space reduce the current number of blank space in one blank space
if the string contain 9 balnk space reduce the current number of blank space in one blank space -
WSsal21
AskWoody LoungerLongs don’t have decimal places – they are integers. Did you mean Double?
sorry…. Double, naturally.
-
WSsal21
AskWoody LoungerLongs don’t have decimal places – they are integers. Did you mean Double?
sorry…. Double, naturally.
-
WSsal21
AskWoody LoungerLongs don’t have decimal places – they are integers. Did you mean Double?
sorry…. Double, naturally.
-
WSsal21
AskWoody LoungerLongs don’t have decimal places – they are integers. Did you mean Double?
sorry…. Double, naturally.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Defunct domain for Microsoft account
by
CWBillow
16 minutes ago -
24H2??
by
CWBillow
1 hour, 26 minutes ago -
W11 23H2 April Updates threw ‘class not registered’
by
WindowsPersister
6 hours, 56 minutes ago -
Master patch listing for April 8th, 2025
by
Susan Bradley
3 hours, 48 minutes ago -
TotalAV safety warning popup
by
Theodore Nicholson
11 hours, 19 minutes ago -
two pages side by side land scape
by
marc
1 day, 10 hours ago -
Deleting obsolete OneNote notebooks
by
afillat
1 day, 12 hours ago -
Word/Outlook 2024 vs Dragon Professional 16
by
Kathy Stevens
15 hours, 35 minutes ago -
Security Essentials or Defender?
by
MalcolmP
18 hours, 20 minutes ago -
April 2025 updates out
by
Susan Bradley
54 minutes ago -
Framework to stop selling some PCs in the US due to new tariffs
by
Alex5723
11 hours, 41 minutes ago -
WARNING about Nvidia driver version 572.83 and 4000/5000 series cards
by
Bob99
1 hour, 46 minutes ago -
Creating an Index in Word 365
by
CWBillow
1 day, 4 hours ago -
Coming at Word 365 and Table of Contents
by
CWBillow
19 hours, 46 minutes ago -
Windows 11 Insider Preview Build 22635.5170 (23H2) released to BETA
by
joep517
2 days, 7 hours ago -
Has the Microsoft Account Sharing Problem Been Fixed?
by
jknauth
2 days, 11 hours ago -
W11 24H2 – Susan Bradley
by
G Pickerell
2 days, 13 hours ago -
7 tips to get the most out of Windows 11
by
Alex5723
2 days, 11 hours ago -
Using Office apps with non-Microsoft cloud services
by
Peter Deegan
2 days, 4 hours ago -
I installed Windows 11 24H2
by
Will Fastie
10 hours, 37 minutes ago -
NotifyIcons — Put that System tray to work!
by
Deanna McElveen
2 days, 16 hours ago -
Decisions to be made before moving to Windows 11
by
Susan Bradley
2 hours, 14 minutes ago -
Port of Seattle says ransomware breach impacts 90,000 people
by
Nibbled To Death By Ducks
3 days ago -
Looking for personal finance software with budgeting capabilities
by
cellsee6
2 days, 8 hours ago -
ATT/Yahoo Secure Mail Key
by
Lil88reb
2 days, 9 hours ago -
Devices with apps using sprotect.sys driver might stop responding
by
Alex5723
3 days, 17 hours ago -
Neowin – 20 times computers embarrassed themselves with public BSODs and goofups
by
EP
4 days, 2 hours ago -
Slow Down in Windows 10 performance after March 2025 updates ??
by
arbrich
1 hour, 46 minutes ago -
Mail from certain domains not delivered to my outlook.com address
by
pumphouse
3 days, 10 hours ago -
Is data that is in OneDrive also taking up space on my computer?
by
WShollis1818
3 days, 21 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.